This week's book giveaway is in the Design forum.
We're giving away four copies of Building Microservices and have Sam Newman on-line!
See this thread for details.
The moose likes Struts and the fly likes Struts Errors Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Building Microservices this week in the Design forum!
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "Struts Errors" Watch "Struts Errors" New topic

Struts Errors

Venkat Babu
Ranch Hand

Joined: Jan 12, 2007
Posts: 47
How to retrieve the saved errors in the action class. I know the saveErrors() set the errors in the request object, but I don't know what's the key to retrieve.

java.util.HashMap map = (java.util.HashMap)request.getAttribute("???");

Thanks a lot.
Merrill Higginson
Ranch Hand

Joined: Feb 15, 2005
Posts: 4864
First of all, the Object put in request scope by SaveErrors is not a HashMap, but an ActionMessages instance. Note that since ActionErrors is a subclass of ActionMessages, it could contain an instance of ActionErrors also.

The best way to retrieve and display it in your JSP is simply to use either the <html:errrors/> or <html:messages/> tag.

If you really want to retrieve it in a scriptlet, this is the code:

[ January 12, 2007: Message edited by: Merrill Higginson ]

Consultant, Sima Solutions
Venkat Babu
Ranch Hand

Joined: Jan 12, 2007
Posts: 47
Great. Thanks.
Have you checked out Aspose?
subject: Struts Errors
It's not a secret anymore!