<snip
from="http://jakarta.apache.org/struts/userGuide/building_controller.html";>

4.5 Exception Handler

You can define an ExceptionHandler to execute when an Action's execute
method throws an Exception. First, you need to subclass
org.apache.struts.action.ExceptionHandler and override the execute method.
Your execute method should process the Exception and return an ActionForward
object to tell Struts where to forward to next. Then you configure your
handler in struts-config.xml like this:

<global-exceptions>
    <exception
      key="some.key"
      type="java.io.IOException"
      handler="com.yourcorp.ExceptionHandler">
</global-exceptions>

This configuration element says that com.yourcorp.ExceptionHandler.execute
will be called when any IOException is thrown by an Action. The key is a key
into your message resources properties file that can be used to retrieve an
error message.

You can override global exception handlers by defining a handler inside an
action definition.

A common use of ExceptionHandlers is to configure one for
java.lang.Exception so it's called for any exception and log the exception
to some data store.

</snip>

--
Andrew Kuzmin
http://www.java201.com


>----- Original Message -----
>From: "muzammil shahbaz" <[EMAIL PROTECTED]>
>To: <[EMAIL PROTECTED]>
>Sent: Tuesday, September 23, 2003 11:59 AM
>Subject: Exception handling in struts


> Hello!
>
> Is there any exception handling mechanism through struts? If we can
> configure our global exceptions in struts-config.xml?
>
> Any comments are welcome.
>
> Thanks in advance.
>
> Muzammil
>


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to