• 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

Struts html:errors tag and JSP

 
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi
How do i use <html:errors> tag in my jsp. I have a LogonForm, the validate() method of the form adds ActionError to the request, Now how do i display those errors in my JSP. What all is required for that should i have a properties file with message id & message value.
What should be the name of the properties file and where it should be placed in my tomcat.
Can someone give me a example covering this subject.
thanks
safi
 
Ranch Hand
Posts: 782
Python Chrome Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
In your JSP, add a <html:errors/> tag.
The property file must be somewhere in the classpath. So I have it in /WEB-INF/classes.
Also the name of the property file must correspond
to the value specified in your web.xml servlet's
param (see parameter: application).
When you create an ActionError class, make sure you pass it a String which corresponds to a
key item in your properties file. You may optionally pass in args but that would mean that
the key entry in ApplicationResources.properties
need to look like this:
some.key = Hello {0}
Cheers,
Pho
 
Sheriff
Posts: 67746
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
And don't forget to put values for errors.header and errors.footer in your resource file or you will get "null"s appearing on the page before and after the list of errors (if any).
The documentation that comes with Struts actually does a pretty good job of describing this.
hth,
bear
[ August 08, 2002: Message edited by: Bear Bibeault ]
 
Bear Bibeault
Sheriff
Posts: 67746
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
And...
If the mechanisms provided by the html:errors tag is not to your liking, it's easy to deal with the error list in your own way since the ActionErrors instance is placed in the request as an attribute with a key of Action.KEY_ERRORS.
You can retrieve this instance and use the methods on it to deal with the errors in any way that you would like.
hth,
bear
[ August 08, 2002: Message edited by: Bear Bibeault ]
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic