File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
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


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "struts 1.0 errors - need quick help" Watch "struts 1.0 errors - need quick help" New topic
Author

struts 1.0 errors - need quick help

Matt Sloan
Greenhorn

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.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

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 JavaPerformanceTuning.com team, Newsletter 039.
Gregg Bolinger
GenRocket Founder
Ranch Hand

Joined: Jul 11, 2001
Posts: 15299
    
    6

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.


GenRocket - Experts at Building Test Data
Matt Sloan
Greenhorn

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!
 
 
subject: struts 1.0 errors - need quick help
 
Similar Threads
html:errors tag not displaying errors :-(
Problem with ApplicationResources properties file.
/struts2tutorial/struts2tutorial/roseindia/showLogin.action) is not available.
Missing message for key index.title
what does .do file extension indicate