Ah, I see the confusion. The Struts framework will use the value from the "key" attribute in the exception element to automatically build ActionErrors for you. You just need to use the <html:errors> tag to display them.
To see where in the framework all of this takes place, check out the source code for the ExceptionHandler class. Hope this helps, Chuck > Thanks Chuck, > > Actually we are porting existing code and hence there are pre defined set of > Exception classes and we have decided not to add any more exception classes. > We are using error code to identify the exact problem. > > >In your case, since you want all errors to go to the same > >page, the path attribute would be "error.jsp" for all of > >your exception elements. > > I agreed that I can define path variables for all the keys to "error.jsp", > like > <global-exceptions> > <exception > key="name.not.found" > type="com.myexception.ServiceException" > path="/error.jsp"/> > > <exception > key="name.system.error" > type="com.myexception.SystemException" > path="/error.jsp"/> > > </global-exceptions> > > But how do I fetch corresponding error message in my "error.jsp" file. Don't > I need to hardcode the "key" in the "error.jsp" like below. If not, please > point out how do I do it. > > -------------------------------------------------------------- > <%@ page language="java" %> > <%@ taglib uri="/WEB-INF/struts-bean.tld" prefix="bean" %> > <%@ taglib uri="/WEB-INF/struts-html.tld" prefix="html" %> > > > <html> > > <p><b>Error Message is :- <bean:message key="name.not.found"/> </b></p> > > </html> > > ------------------------------------------------------------------- > > Thanks, > Harvinder > > -----Original Message----- > From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]] > Sent: Monday, October 07, 2002 8:44 PM > To: Struts Users Mailing List > Subject: RE: Declarative Exception handling with Struts 1.1-b2 > > > I may be misunderstanding your situation completely. If > I have, I apologize ahead of time. Here's the short > version of what I think. > > Can you not throw more specific exceptions, ones that > imply a little more about what went wrong? Then setup > exception elements in the global section (or in the > Action mappings if they are specific to the Action) and > configure the application resource key for that specific > exception. > > I'm sure you understand this, but let me emphasize > anyway, the point of declarative exception handling is > that you shouldn't have to do anything programmatically > to display errors. You specify what the error page is > using the "path" attribute in the exception element. In > your case, since you want all errors to go to the same > page, the path attribute would be "error.jsp" for all of > your exception elements. > > Does that make sense? Again, let me know if I > misunderstood the question completely. > > Chuck > > Chuck, > > > > I have gone through this chapter but I didn't find anyway to retrieving key > > during run time for declarative exception handling. My requirement is to > > maintain single error.jsp file, and hence the error key should not be > > hardcoded. I am specifying a global exception, say, java.lang.Exception and > > for two different situation and I am throwing new Exception("key1"), and > new > > Exception(key2). I would love to get key (key1 or key2) in runtime and > > replacing it will appropriate messages from ApplicationResources.properties > > file. Please point out if I missed sth in chapter 10 and there is a way to > > handle the situation I mentioned above. > > > > Thanks, > > Harvinder > > > > > > -----Original Message----- > > From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]] > > Sent: Monday, October 07, 2002 5:50 PM > > To: Struts Users Mailing List > > Subject: Re: Declarative Exception handling with Struts 1.1-b2 > > > > > > If you haven't already, may I suggest you download the > > draft of Chapter 10 from my book. It covers Struts and > > Exception Handling (both programmatic and declarative). > > > > Here's a link: > > http://www.theserverside.com/resources/strutsreview.jsp > > > > Sorry for the shameless plug, but I think the material > > will help. > > > > Chuck > > > Hi, > > > Can anybody help me in understanding declarative exception handling with > > > Struts1.1b2? My requirement is maintaining only single "error.jsp" file, > > > which should be displayed when an exception is thrown. We are having > > multiple > > > exception classes and when an exception is thrown an error id is > associated > > > with it to get appropriate message. If I put all the error code vs error > > > messages in ApplicationResources.properties, there should be a way to > fetch > > > the error code from the thrown exception, and then displaying the > > appropriate > > > message. Any help is appriciated. > > > Thanks, > > > Harvinder > > > > > > -- > > > To unsubscribe, e-mail: > > <mailto:[EMAIL PROTECTED]> > > > For additional commands, e-mail: > > <mailto:[EMAIL PROTECTED]> > > > > > > > -- > > To unsubscribe, e-mail: > <mailto:[EMAIL PROTECTED]> > > For additional commands, e-mail: > <mailto:[EMAIL PROTECTED]> > > > > > > -- > > To unsubscribe, e-mail: > <mailto:[EMAIL PROTECTED]> > > For additional commands, e-mail: > <mailto:[EMAIL PROTECTED]> > > > > -- > To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]> > For additional commands, e-mail: <mailto:[EMAIL PROTECTED]> > > > -- > To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]> > For additional commands, e-mail: <mailto:[EMAIL PROTECTED]> > -- To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]> For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>

