tags:

views:

174

answers:

1

is it possible to set a session attribute using JSTL from a hidden input in the jsp page?

A: 

You can use <c:set> to set an attribute in an arbitrary scope and you can use ${param} to access a request parameter.

<c:set var="foo" value="${param.foo}" scope="session" />

This will basically do session.setAttribute("foo", request.getParameter("foo")); during rendering of the response of the JSP result page with this line where the form is been submitted to. In this example, the hidden field should have the name foo.

If you actually need to set it before forwarding the request/response to the JSP, then you'll need to do this (indirectly) in the responsible controlling/postprocessing servlet class where the form is been submitted to.

If you actually need to set it during displaying the form, then just set the value directly using <c:set> instead of passing from a hidden input. E.g.

<c:set var="foo" value="theValue" scope="session" />
BalusC