The moose likes Struts and the fly likes Using JSP scriptlet in Bean:write tag Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "Using JSP scriptlet in Bean:write tag" Watch "Using JSP scriptlet in Bean:write tag" New topic

Using JSP scriptlet in Bean:write tag

Amirr Rafique
Ranch Hand

Joined: Nov 14, 2005
Posts: 324

How can we use JSP scriptlet in <bean:write> tag e.g.
<bean:message key="homepage.text.announcements.text.first"/> Can I do following
<bean:message key="homepage.text.announcements.text.first<%=institute%>"/>
Where <%institute%> is my variable having different values. Basically I wanna select key dynamically.

Anybody can please help


"Know where to find the solution and how to use it - that's the secret of success."
Merrill Higginson
Ranch Hand

Joined: Feb 15, 2005
Posts: 4864
The rule with scriptlets used in attributes of a Struts tag is "all or nothing", meaning the entire attribute must be a scriptlet, or no part of it can be a scriptlet.

Given this rule, the following should work:

<bean:message key='<%="homepage.text.announcements.text.first"+institute%>'/>

Consultant, Sima Solutions
I agree. Here's the link:
subject: Using JSP scriptlet in Bean:write tag
It's not a secret anymore!