Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to use ActionMessages

Status
Not open for further replies.

pajarokillo

Programmer
May 3, 2004
30
ES
Hi!, my problem is the following, i want to save a ActionMessages object in the session object and then to display it in my JSP, how i can do it?, thanks
 
In your action class, you set the message like this

Code:
ActionMessages messages = new ActionMessages();    
messages.add("statusMessage", new ActionMessage("message.key"));
saveMessages(request.getSession(), messages);
// you can save it to request too if you don't need to the message to appear in subsequence page
// saveMessages(request, messages);

where "message.key" is one of the property key in the Application Resource file.


In the JSP
Code:
<logic:messagesPresent message="true">
   <html:messages id="message" message="true" property="statusMessage">
      <bean:write name="message"/>
   </html:messages>
</logic:messagesPresent>
 
ok byam, very thanks, i didn't know that the method saveMessages(HttpSession,ActionMessages) it existed, it's version 1.2 of Struts and i use 1.1, i'll have to change the version.

Very thanks
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top