In the struts-config.xml file, add an <exception> element to this action. You can also put it in the <global-exceptions> section if more than one action will utilize this exception handler.
Here's an example action mapping using an exception element: <action path="/signin" type="com.cavaness.beer4all.security.LoginAction" scope="request" name="loginForm" validate="true" input="/signin.jsp"> <exception handler="com.foo.MyExceptionHandler" key="error.invalidlogin" path="/signin.jsp" scope="request" type="com.cavaness.beer4all.common.exceptions.InvalidLogi nException"/> <forward name="Success" path="/index.jsp" redirect="true"/> <forward name="Failure" path="/signin.jsp"/> </action> Notice the <exception> element. The handler attribute is the fully-qualified class name of your handler. As you have done, it must extend the default handler. The type attribute specifes the fully-qualified exception class for when you want to call this exception handler. You can put "java.lang.Exception" if you want this handler to process all exceptions thrown during this Action. Hope that helps, Chuck > I have a class that extents the default struts ExceptionHandler ( see below). > > Now, when an exception occurs in the 'Action' class..., how do i make > sure that > the 'execute()' in 'MyExceptionHandler' is executed instaed of the > default ExceptionHandler? > > > public class MyExceptionHandler extends ExceptionHandler { > > private MyChainedException tCE = null;= > > /** > * Constructor for an external message > * @param tce of type MyChainedException > * > */ > public MyExceptionHandler(MyChainedException tce) { > this.tCE = tce; > > } > public ActionForward execute(Exception ex, > ExceptionConfig config, > ActionMapping mapping, > ActionForm formInstance, > HttpServletRequest request, > HttpServletResponse response) > throws ServletException { > ActionForward forward = null; > ActionError error = null; > String property = null; > > /* Get the path for the forward either from the exception element > * or from the input attribute. > */ > String path = null; > if (config.getPath() != null) { > path = config.getPath(); > }else{ > path = mapping.getInput(); > } > // Construct the forward object > forward = new ActionForward(path); > > /* Figure out what type of exception has been thrown. The Struts > * AppException is not being used in this example. > */ > if( tCE instanceof MyChainedException) { > // This is the specialized behavior > > Throwable t = tCE.getCause(); > String messageKey = t.getClass().getName(); > error = new ActionError( messageKey ); > > } > > // Store the ActionError into the proper scope > // The storeException method is defined in the parent class > storeException(request, property, error, forward, = > config.getScope()); > > return forward; > } > > > } > > > -- > 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]>