简体   繁体   中英

How get input value in scriplet on jsp

I have html code:

<input type="text" name="username" id="username">

How can I get username's value in my scriplet ?

 <% String username= request.getParameter("username");
 %>

But it doesn't work for me How can I solve this?

First make sure that request Object is only available when you send the request to the server or Submit the form .

  • on Client side pass Some action inside form tag and mapped into XML file

     <form action="Submit.do"> 
  • from server side like servlet/Strtus/JSP you can access request object using

     <% request.getParameter("inputid");%> 
  • if you calling Same page after Submitting the data then on scriptlet check for request object if it null then don't perform any action else get the object

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM