You can access request parameters by implicit ${param}
variable.
E.g. http://example.com/context/page.jsp?foo=bar
in combination with
<c:if test="${param.foo == 'bar'}">
The foo's param value is bar!
</c:if>
<c:if test="${param.foo != 'bar'}">
The foo's param value is not bar, it is: ${param.foo}
</c:if>
would show the first condition.
If you actually want to retain some hidden input element in subsequent requests (which wasn't really made clear in your question), then all you basically need to do is:
<input type="hidden" name="foo" value="${param.foo}">
Update: as per your update: you need to give the input element a name as well. Thus, e.g.
<input type="text" name="id1" value="${param.id1}" />
This way it's available by request.getParameter("id1")
and inherently also ${param.id1}
. Do you see it now?
Update 2: as per your comment here: certainly this is related to enctype="multipart/form-data"
. With this encoding, the request parameters aren't in the parameter map anymore, but instead in the request body, because of the mixup with binary data (file uploads). It's going to be a long story to explain it all, but basically you need to parse the request yourself. If you're on Servlet 2.5 or older, then the Apache Commons FileUpload is very helpful here. Read especially "User Guide" and "Frequently Asked Questions" over there to see code examples and to learn how to use it the right way (also in MSIE!). You can even decide to abstract the FileUpload away so that you can stick using HttpServletRequest#getParameter()
and ${param}
the usual way, also see this article.
If you're already on Servlet 3.0, then you can just make use of HttpServletRequest#getParts()
. You can even abstract it away so that you can stick using HttpServletRequest#getParameter()
and ${param}
the usual way, also see this article.
Update 3: Oh, you really don't want to use JSP to do all the processing. There it is not for. It's high time to learn Servlet
. Besides, when using a Filter
which puts all parameters from the request body back in the request parameter map (as described in the both articles), you also don't necessarily need a Servlet
after all.