struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Wendy Smoak <>
Subject Re: How to use bean property as value for html hidden field
Date Fri, 27 May 2005 16:42:25 GMT
From: "Jim Coble" <>

> In my JSP html:form, I want to have the value of a hidden field set to the
> (String) value of a property of a request-scoped attribute.  I tried using
> a "bean:write" as the argument to the "value=" property of the
> "html:hidden" tag, like this ...
> <html:hidden property="resource" value="<bean:write name=\"resource\"
> property=\"code\" scope=\"request\"/>" />

You cannot nest JSP tags.  Set the value of the form property 'resource' to
the correct value in the Action, before forwarding to the JSP, and the
framework will render the hidden field with the value set.  What's placing
the 'resource' bean in the request?  Instead of/in addition to that, do
form.setResource( resource.getCode() );

If for some reason that's unacceptable, you could always use a plain old
HTML <input> tag and nest the <bean:write> in that.

Or you could use Struts-EL and JSTL, but that's overkill for this problem.
I assume you aren't on a JSP 2.0 container so that the expression
${resource.code} would work.

Wendy Smoak

To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message