Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Can i Use my action to throw error

 
Jagmohan Negi
Greenhorn
Posts: 27
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 4864
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic