File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Struts and the fly likes How can this be done better (html:link) Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "How can this be done better (html:link) " Watch "How can this be done better (html:link) " New topic

How can this be done better (html:link)

Ray Beaumont

Joined: Nov 25, 2003
Posts: 7
I've got a generic page and I'd like to pass text in to be displayed at the top. My Action class puts the Resource into the session:
HttpSession session = request.getSession();
session.setAttribute("logon_message", "k35.logon.postad");
I'd ideally like to be able to write a single tag that would write the String that corresponds to k35.logon.postad in my Application Resources file. Can anybody suggest an improvement on the following?
<logic resent name="logon_message">
<p class="heading">
<bean:message key="<%=session.getParameter("logon_message")%>"/>
</logic resent>
David Yutzy
tumbleweed and gunslinger
Ranch Hand

Joined: Jun 29, 2001
Posts: 192
Why not have your action class hit the resource bundle and place the actual "message" in session, rather than the name?
That way, in the JSP file, you would just have:

Better yet, place it in page or request scope, unless you have a specific reason to place it in session.
[ December 12, 2003: Message edited by: David Yutzy ]
I agree. Here's the link:
subject: How can this be done better (html:link)
It's not a secret anymore!