• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Can i Use my action to throw error

 
Greenhorn
Posts: 27
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Ranch Hand
Posts: 4864
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
reply
    Bookmark Topic Watch Topic
  • New Topic