struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
Subject Re: common error page in struts2 application
Date Fri, 31 Jul 2009 08:29:13 GMT
I think you can catch it, then do log.error(e.getMessage(),e); and then throw e;

From: Bhaarat Sharma <>
To: Struts Users Mailing List <>
Sent: Friday, July 31, 2009 5:03:34 AM
Subject: Re: common error page in struts2 application

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, I though I
can have a chainAction so something like.
               <result name="Exception" type="chain">
                  <param name="actionName">ErrorPage</param>
                 <param name="namespace">/error</param>

            <exception-mapping exception="java.lang.Exception"
        <action name="selectionPage" class="reports.ReportSelection">

<package name="secure"  namespace="/error">
    <action name="ErrorPage" class="com.myErrorClass">
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.


On Thu, Jul 30, 2009 at 11:40 PM, Bhaarat Sharma <>wrote:

> will the global exception not recognize the exception if I am catching it??
> I need to catch it because I want to put it in the logs.  However, in my
> example, if i am catching the exception then I am seeing that the error page
> defined with global-results is not coming up.
> do the global exception mappings only work for 'non caught' exceptions?
> On Thu, Jul 30, 2009 at 4:07 PM, Dave Newton <>wrote:
>> Bhaarat Sharma wrote:
>>> Is there a way to just add [exception mapping] somewhere so that all
>>> 20 package mappings see it?
>>> most of the packing are using struts-default
>> You could create your own base package and extend from that. Package
>> extension is also documented on the Struts 2 wiki (briefly):
>> Dave
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail:
>> For additional commands, e-mail:

  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message