Did you sort this out already Andy?
I can't remember whether the web.xml error page is the same mechanism as the
error page declaration.
As for grabbing the exception object, I guess it must be in some servlet
container scope like the request attributes under some key or other.
You could even use an interceptor to check for exceptions after the result.
Sorry I can't be more specific, I guess it leaves up to you to try out different
strategies. Presuming that you're not using templating of any kind since you
didn't mention it, it shouldn't be too difficult. But you also didn't say what
the problem was with your web.xml approach.
I can see you having problems though if you don't buffer your response.
Regards
Adam
Andy on 22/01/09 14:18, wrote:
Thanks for the response. What I'd like to do is allow an action to handle
the JSP exception instead of a JSP, so that I can save the exception to the
DB and then redirect the user to an error page. The problem I am having is
trying to get the exception object to pass to the action. This is what I was
trying to use (web.xml):
<error-page> <exception-type>java.lang.Exception</exception-type>
<location>/canvas.action</location> </error-page>
Date: Thu, 22 Jan 2009 11:19:35 +0000 From:
ahardy.str...@cyberspaceroad.com To: user@struts.apache.org Subject: Re:
Handling JSP exceptions in Struts2
Andy on 20/01/09 17:49, wrote:
Using the Exception interceptor works great for catching exceptions throw
by actions. However I am wondering what is the recommended method for
catching and handling exceptions thrown by a JSP? I assume that JSP
exceptions are outside the S2 scope and are to be handled at the
container level?
Assumption correct.
Your situation might be quite simple if you have a basic JSP. Put in an
error declaration
<%@ page errorPage="/WEB-INF/jsp/error.jsp" %>
and handle it there.
If you're using multiple JSPs with a templating system like tiles, it gets
more complicated. I do and I put a meta-redirect in my error JSP so that
the browser doesn't show the mix of correct and broken fragments.
--------------------------------------------------------------------- To
unsubscribe, e-mail: user-unsubscr...@struts.apache.org For additional
commands, e-mail: user-h...@struts.apache.org
_________________________________________________________________ Windows
Liveā¢: E-mail. Chat. Share. Get more ways to connect.
http://windowslive.com/explore?ocid=TXT_TAGLM_WL_t2_allup_explore_012009
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscr...@struts.apache.org
For additional commands, e-mail: user-h...@struts.apache.org