dimanche 19 avril 2015

Hidden Input is giving null in servlet

This question has been asked before on the forum, but I am unable to figure out from that. So, I am passing a form to a servlet,



<form method="Post" action="../JDBCConnector">
<label for="fname">First Name : &nbsp;</label>
<input type="text" name="fname" id="fname">

<label for="lname">Last Name : &nbsp;</label>
<input type="text" name="lname" id="lname">

<label for="uname">Username : &nbsp;</label>
<input type="text" name="uname" id="uname">

<label for="pswrd">Password : &nbsp;</label>
<input type="password" name="pswrd" id="pswrd">

<input type="hidden" name="hide" id="hide" value=1>
<button type="submit" name="submitButton" id="submitButton">Submit &nbsp;</button>
</form>


The servlet side code is,



String name = request.getParameter("hide");
response.getWriter().print(name);
String FNAME = request.getParameter("fname");
response.getWriter().print(FNAME);


The output is



null TestName



Basically, I am getting a null value in the servlet for the hidden field. Can someone please tell what mistake I have made?


Aucun commentaire:

Enregistrer un commentaire