raptor496
raptor496

Reputation: 267

Sending hidden input field values comes back null

I have one input field that is hidden. I'm using it as a placeholder to send the value to a scriptlet. Like below, but the value of the hidden field is always null. When I remove the hidden tag everything works correctly.

  <form method=post action="test.jsp">

  <input type="hidden" name="name" id="name" >

  <button class="button primary" type="submit">Submit</button></form>

Then in scriplet getting the value, but it is nullpointer exception

           <%
            String x = null;

            x  = request.getParameter("name");

            %>

Upvotes: 0

Views: 2655

Answers (2)

Suresh
Suresh

Reputation: 49

It should come, only disabled fields data u will not getting in req.getParameters()

u missed value attribute

Upvotes: 0

Antoine
Antoine

Reputation: 1445

You should specify a value for your input hidden field. Something like:

<input type="hidden" name="country" value="Norway">

Try it

Upvotes: 2

Related Questions