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 how to define global exception in struts ? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "how to define global exception in struts ?" Watch "how to define global exception in struts ?" New topic
Author

how to define global exception in struts ?

harish pathak
Ranch Hand

Joined: Dec 17, 2005
Posts: 51
Hi All,

Anybody please tell how to define global exception in struts ?

Thanks in advance

harish
Aaron Ting
Ranch Hand

Joined: Dec 13, 2005
Posts: 78
Originally posted by harish pathak:
Hi All,

Anybody please tell how to define global exception in struts ?

Thanks in advance

harish


Greetings harish,


You could actually define the global exception in Struts through the struts-config.xml

There are several attributes which you have to define in the .xml file.

The files are as follows,

type - Specifies the fully qualified class name of the exception that the handler is for.

path - The page which the config file will redirect the user to when the exception is being thrown.

key - The name of a key in the ApplicationResources.properties file that will be used to populate an ActionError object that will be passed to the page with association to the path attribute.


For example, i have an exeception class, AaronException, a key in my ApplicationResources.properties known as error.AaronException and a JSP page, aaron.jsp, the sample code configuration in struts-config.xml will goes,



P.S.: You could also handle exceptions within the action-mappings...

*just my 2cents worth*


If you can't convince them, confuse them!
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: how to define global exception in struts ?