Reputation: 725
i've a hidden field value
<input type="hidden" id= "i1" name="h1" value="Request Recieved"/ >
i need the value to be read in another jsp file whose reference is mentioned in the current file.
i'm using out.println(request.getParameter("h1"));
but its printing null..
Upvotes: 2
Views: 10776
Reputation: 1108722
This will only work when you navigate to another JSP by a <form>
which has this field embedded.
E.g. page1.jsp
:
<form action="page2.jsp">
<input type="hidden" name="foo" value="bar">
<input type="submit">
</form>
And page2.jsp
:
<p>Hidden value: ${param.foo}</p>
That's all. It won't work when you navigate by a link <a>
or submit another form where the hidden field is not included.
(the ${param.foo}
does effectively the same as out.print(request.getParameter("foo"))
, only in a less vintage and ugly manner. See also How to avoid Java code in JSP)
Upvotes: 2