struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Greg Lindholm <greg.lindh...@gmail.com>
Subject Re: how to get exception stack after redirect to action
Date Tue, 25 Aug 2009 17:21:00 GMT
The exception will not persist across the redirect unless you were to save
it in the session. If you want to do this then you could take a look at [1]
RedirectMessageInterceptor for an example of how to saveand retrieve the
exception in the session.

However, what I do to handle exceptions is have a global result "error"
which just goes to a jsp page.
    <global-results>
      <result name="error">/struts/Error.jsp</result>
    </global-results>

In the Error.jsp page I use some ognl to call a method "notifyAdmiin()" and
pass it the exception.

<%-- Dummy expression to notify the admin --%>
<s:if test="notifyAdmin(exception)"></s:if>

I can than do any handling of the exception in my notifyAdmin() method, this
method is in my base Action class so is available from all actions.


[1]
http://glindholm.wordpress.com/2008/07/02/preserving-messages-across-a-redirect-in-struts-2/

On Tue, Aug 25, 2009 at 12:43 PM, Louis Voo <jlvoo@yahoo.com> wrote:

> Hi,
>
> What I'm trying to do is when exception happen, it redirect to
> ExceptionHandlingAction and do something extra like sending email. My
> question are
> 1) How to get the exception in ExceptionHandlingAction ? I've this setter
> in the action public void setException(Exception exception), but nothing is
> set
> 2) How to get the original request? I want to print out all the request
> parameters which user submit.
> 3) If I use result type "chain" I got this error message:
>  Infinite recursion detected:
> [/exception/exception!execute,
> /exception/ExceptionHandling, /exception/ExceptionHandling]
> - [unknown location]
>
>
> Here is my configuration:
>
>                <global-results>
> <result name="errorAction" type="redirectAction">ExceptionHandling</result>
> <result name="error">/WEB-INF/pages/error/Error.jsp</result>
> </global-results>
>
> <global-exception-mappings>
> <exception-mapping exception="java.lang.Exception"
> result="errorAction" />
> </global-exception-mappings>
> <action name="ExceptionHandling"
> class="demo.action.ExceptionHandlingAction"/>
>
>
>
> Thanks
> Louis

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