• 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 1.0 errors - need quick help

 
Greenhorn
Posts: 26
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Unfortunately the powers that be have determined that struts 1.0 is what is to be used. With that in mind, I am trying to implement some validation and error handling. So far, I am doing pretty good. My action class is catching the errors, creating the ActionMessages and saving them. The only problem is, my error message isn't being displayed in my jsp.

Here is what I have so far.
My action class:


My jsp:


I have also created the following properties file:
# -- standard errors --
errors.header=<br><div class="leftSt"><font color="red" id="bigerSt">Validation Error</font></div><br><span class="leftSt">The following validation error(s) occurred:</span><UL>
errors.prefix=<LI><span class="leftSt">
errors.suffix=</span></LI>
errors.footer=</UL><hr align="center" width="90%" noshade />

#-- WebRoads --

errors.duplicate.closedDay= Closed Day{0} already exists

and my web.xml:


I think the problem has to do with the application.properties file not being found. I have created a directory called resource at the root of my code directory. Didn't work. I also stuck it in my web-inf directory and modified my web.xml - still didn't work.

Please help!!!

TIA
 
Matt Sloan
Greenhorn
Posts: 26
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
well I was able to figure it out. I had to replace the <html:errors/> tag in the jsp with the following :



where "errors" is the name of my ActionMessage object defined in my Action class.
 
Ranch Hand
Posts: 374
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The real problem with your code is that you are saving your errors as a message -- not an error. Instead of invoking saveMessages, try saveErrors. Then you don't have to muck about with the errors tag and can simply do as you originally intended -- <html:errors />
 
Ranch Hand
Posts: 15304
6
Mac OS X IntelliJ IDE Chrome
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
msloan

Welcome to Javaranch!

We don't have too many rules around here but we do have a Naming Policy. Please read this and adjust your display name accordingly.

Thanks.
 
Matt Sloan
Greenhorn
Posts: 26
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
David, thanks for the advice - switched everything over to ActionErrors and ActionError - used the <html:errors/> tag - works perfect!

Gregg - changed the name - Sorry about that.

Thanks again!
 
Attractive, successful people love this tiny ad:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic