You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Stephen Earl <se...@smartpoint.com> on 2000/10/28 20:29:11 UTC
Session attribute referenced within struts:message tag
Hi,
Can anyone tell me how get the following strugs tag to work?
<struts:message key="labels.forms.userType.<%=
session.getAttribute("userType") %>" />
In this case I have an ApplicationResources. properties file containing the
following entries:
labels.forms.userType.1=Administrative User
labels.forms.userType.2=Guest User
etc...
I don't want to do an if-then to determine what key to pass... I need to
generate the key string and pass it to the struts:message tag.
Am I missing something basic here?
Thanks in advance,
Stephen Earl
Re: Session attribute referenced within struts:message tag
Posted by "Craig R. McClanahan" <Cr...@eng.sun.com>.
Stephen Earl wrote:
> Hi,
>
> Can anyone tell me how get the following strugs tag to work?
>
> <struts:message key="labels.forms.userType.<%=
> session.getAttribute("userType") %>" />
>
It is not legal JSP syntax to mix a constant string and a runtime
expression
like this. To accomplish what you want, try the following:
<struts:message key='<%= "labels.forms.userType." +
session.getAttribute("userType") %>'/>
Note the use of single quotes around the value for the "key" attribute,
so that you don't have to escape the double quotes used within the Java
expression.
> Stephen Earl
Craig McClanahan