aspose file tools
The moose likes Struts and the fly likes Can i Use my action to throw error Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Badass: Making Users Awesome this week in the Game Development forum!
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "Can i Use my action to throw error" Watch "Can i Use my action to throw error" New topic

Can i Use my action to throw error

Jagmohan Negi

Joined: Aug 24, 2005
Posts: 27
I am using struts framework with validation support.But i am not using the html and bean tag lib. of struts framework,can i still throw error using action classes.
Merrill Higginson
Ranch Hand

Joined: Feb 15, 2005
Posts: 4864
When you do validation in the execute() method of an Action class, you populate an ActionMessages object with ActionMessage objects and then place it in request scope.

It would certainly be possible to retrieve this object from request scope in your JSP and write your own code to display the errors. The question remains: Why would anyone want to when it's so easy to do it with the <html:errors> tag or the <html:messages> tag?

If you really want to do it without using the html:xxx tags, I'd download the Struts source code and see how Struts accomplishes the task of displaying errors. Then use this as a basis for writing your own code.

Consultant, Sima Solutions
I agree. Here's the link:
subject: Can i Use my action to throw error