tags:

views:

86

answers:

1

How do I assign hidden value to JSTL variable?

Example:

<input type="hidden" name="userName" value="Administrator" />
<c:set var="user" value="" />  // How do I set hidden variable value (Administrator) here?
+1  A: 

I assume that you actually mean: "How do I assign submitted hidden input value to a JSTL variable?", because the question as you currently state makes no sense. You could just copy the value in the tag.

You can access request parameters by the implicit EL object ${param} which can be accessed like a Map.

<c:set var="user" value="${param.userName}" />

Behind the scenes, this assigns the result of request.getParameter("userName") to a variable name user in the page scope.


That said, I question the value of this need. Maybe it's time to learn a bit more about servlets as page controllers and Javabeans as model objects?

See also:

BalusC