It's not a secret anymore!
The moose likes Struts and the fly likes struts 1.0 errors - need quick help Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "struts 1.0 errors - need quick help" Watch "struts 1.0 errors - need quick help" New topic

struts 1.0 errors - need quick help

Matt Sloan

Joined: Aug 27, 2004
Posts: 26
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.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 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!!!

Matt Sloan

Joined: Aug 27, 2004
Posts: 26
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.
David Hibbs
Ranch Hand

Joined: Dec 19, 2002
Posts: 374
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 />

"Write beautiful code; then profile that beautiful code and make little bits of it uglier but faster." --The team, Newsletter 039.
Gregg Bolinger
GenRocket Founder
Ranch Hand

Joined: Jul 11, 2001
Posts: 15302


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.


GenRocket - Experts at Building Test Data
Matt Sloan

Joined: Aug 27, 2004
Posts: 26
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!
I agree. Here's the link:
subject: struts 1.0 errors - need quick help
It's not a secret anymore!