Java Mailing List Archive

http://www.junlu.com/

Home » Home (12/2007) » Struts 2 »

Global Exception not working for me

Prakash Inuganti -X (pinugant - Digital-X, Inc. at Cisco)

2006-12-17


Hi,

The issue I have might be due to something very basic I am missing but
for me I can't make this work. I am trying to capture any errors that
happen in my application and show them in an error page.

In my LookupDispatchAction class I have

public ActionForward save(ActionMapping mapping, ActionForm form,
     HttpServletRequest request, HttpServletResponse
response)
     throws Exception {
   try{
     // Code
   }catch(Exception e){
     e.printStackTrace();
     logger.error(e.getMessage());
     throw e;
   }
   return (mapping.findForward("success"));
}

In my struts-config I have a global Exception and key below defined in
Resources.properties file.

<global-exceptions>
 <exception key="my.exception" type="java.lang.Exception"
path="/pages/Error.jsp"></exception>
</global-exceptions>

I tried forcing errors but my error page never gets displayed. My
application just ignores the errors and goes to success page. I can see
stack trace in my console.

What am I doing wrong? Any help is appreciated.

Thanks in Advance
Prakash

©2008 junlu.com - Jax Systems, LLC, U.S.A.