struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Ciaran Hanley" <ciaran.han...@sentenial.ie>
Subject Problem displaying ActionMessages in JSP
Date Fri, 09 Jan 2004 16:44:17 GMT
Hello 
Can anybody help me? I am trying to display messages on my JSP based on
whether an insertion to the DB was successful or not.
 
Properties file:
 
dbsuccess.add = Database Success: Details Added
dberror.add = Database Error: Unable To Add Details At This Time
 
 
 
Action Class:
 
/* create ActionErrors instance to hold success/failure messages */
ActionMessages messages = new ActionMessages();
            
try
{
......business logic
 
      messages.add(ActionMessages.GLOBAL_MESSAGE, new
ActionMessage("dbsuccess.add"));
setSession(messages, request);
} 
catch (Exception e) 
{
      messages.add(ActionMessages.GLOBAL_MESSAGE, new
ActionMessage("dberror.add""));
setSession(messages, request);
}
 
 
private void setSession(ActionMessages messages, HttpServletRequest
request)
{
      /* put the messages in the session */
      request.getSession().getServletContext().setAttribute("messages",
messages);
}
 
 
JSP file:
 
<logic:messagesPresent message="true">
  <font color="red"><UL>
    <html:messages id="messages">
      <LI>
        <bean:write name="messages" />
      </LI>
    </html:messages>
  </UL></font><hr>
</logic:messagesPresent>
 
Nothing is being printed at the top of the page, the insertion into the
database works fine but I cant get the success message up. Does anybody
know why this is happening?
 
Thanks,
Ciaran

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message