What I do, instead of chaining the global error result to an error action, is I use ognl in my error.jsp page to call a method and pass the exception so it can be logged etc. In my base action class I have a notifyAdmin(Exception) method.
In error.jsp: <%-- Dummy expression to notify the admin --%> <s:if test="notifyAdmin(exception)"></s:if> On Fri, Jul 31, 2009 at 12:03 AM, Bhaarat Sharma <bhaara...@gmail.com>wrote: > Sorry I am a little confused. Basically I need to be able to log the > message by doing log.error(e.getMessage(), e); However, if i catch the > error and put it in the catch block then the global error page does not > come > up (I am assuming because the exception is caught?) > > If I do not catch the exception, then the error page shows up, however, I > have no way to do log.error(e.getMessage(), e); > > After reading, > http://struts.apache.org/2.0.6/docs/exception-configuration.html I though > I > can have a chainAction so something like. > <package...> > <global-results> > <result name="Exception" type="chain"> > <param name="actionName">ErrorPage</param> > <param name="namespace">/error</param> > </result> > </global-results> > > <global-exception-mappings> > <exception-mapping exception="java.lang.Exception" > result="Exception"/> > </global-exception-mappings> > <action name="selectionPage" class="reports.ReportSelection"> > <result>/reports/SelectionPage.jsp</result> > </action> > > </package> > <package name="secure" namespace="/error"> > <action name="ErrorPage" class="com.myErrorClass"> > <result>errorpage.jsp</result> > </action> > </package> > So finally, if i do not catch the error, the control will go to > com.myErrorClass. Will I be able to do log.error(e.getMessage(), e); in > that class?? I dont think it will be available as originally the error was > thrown in reports.ReportSelection class. > > I'd appreciate any help to guide me in right direction. > > Thanks >