I forgot to mention, a lot of the content on http://www.stripesframework.org/display/stripes/Exception+Handling
is actually incorrect due to this problem. That page is where I lifted this stuff from many years ago. [Description: http://www.stripesframework.org/images/icons/emoticons/check.gif] The ExceptionHandler is invoked from the Stripes Filter. This allows it to handle exceptions generated in ActionBeans, in JSPs and even in other Servlet Filters that are lower down the chain than the Stripes Filter. Is request.getRequestDispatcher("/error.jsp").forward(request, response); Any more likely to succeed as opposed to return new ForwardResolution(...); (the page uses both idioms in the example) From: Newman, John W [mailto:newma...@d3onc.com] Sent: Tuesday, August 16, 2011 1:26 PM To: Stripes Users List (stripes-users@lists.sourceforge.net) Subject: [Stripes-users] Exception handler - cannot forward to error page after exception in original page forward. Hi All, I've had this minor problem for a while now, and I'm not really sure what I'm supposed to do differently. Consider an action bean that throws an exception in the middle of the forward resolution while processing the page: class ActionBean { public Resolution throwExceptionWithinJsp() { return new ForwardResolution("/WEB-INF/some-jsp-page-that-throws-an-exception.jsp"); } } We have an exception handler configured, to catch any errors and then take the user to a friendly error page instead of giving them the nice old tomcat stack trace view. class ExceptionHandler() { public Resolution handleGeneric(Throwable t) { log.error(t); return new ForwardResolution("/WEB-INF/errors/500.jsp"); } } So we've got an exception trace from that jsp page (or freemarker in my case): ERROR: Expression xyz is undefined on line 105, column 38 in WEB-INF/some-jsp-page-that-throws-an-exception.jsp at freemarker.template.Template.process(Template.java:237) at freemarker.ext.servlet.FreemarkerServlet.process(FreemarkerServlet.java:458) at freemarker.ext.servlet.FreemarkerServlet.doPost(FreemarkerServlet.java:405) at javax.servlet.http.HttpServlet.service(HttpServlet.java:710) at javax.servlet.http.HttpServlet.service(HttpServlet.java:803) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206) at net.sourceforge.stripes.controller.DynamicMappingFilter.doFilter(DynamicMappingFilter.java:345) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206) at org.apache.catalina.core.ApplicationDispatcher.invoke(ApplicationDispatcher.java:654) at org.apache.catalina.core.ApplicationDispatcher.processRequest(ApplicationDispatcher.java:445) at org.apache.catalina.core.ApplicationDispatcher.doForward(ApplicationDispatcher.java:379) at org.apache.catalina.core.ApplicationDispatcher.forward(ApplicationDispatcher.java:292) at net.sourceforge.stripes.action.ForwardResolution.execute(ForwardResolution.java:110) Now the exception handler kicks in, logs the error, and now tries to forward the user over to our nice 500 page. But the problem is, they never actually get to the error page - just a blank response, due to yet another exception caused by the second forward: ERROR [org.apache.catalina.core.ContainerBase.[jboss.web].[localhost].[/].[default]] Servlet.service() for servlet default threw exception java.lang.IllegalStateException: Cannot forward after response has been committed at org.apache.catalina.core.ApplicationDispatcher.doForward(ApplicationDispatcher.java:302) at org.apache.catalina.core.ApplicationDispatcher.forward(ApplicationDispatcher.java:292) at net.sourceforge.stripes.action.ForwardResolution.execute(ForwardResolution.java:110) at net.sourceforge.stripes.exception.DefaultExceptionHandler$HandlerProxy.handle(DefaultExceptionHandler.java:107) at net.sourceforge.stripes.exception.DefaultExceptionHandler.handle(DefaultExceptionHandler.java:140) at net.sourceforge.stripes.controller.StripesFilter.doFilter(StripesFilter.java:249) So since I can't return a forward resolution if I've already executed one, what am I supposed to do to get the user over to the error page? In general, is returning a resolution from the exception handler a valid idea on stripes' part? I know I'm not the only one who has this requirement of a "forward" to a friendly 500 page. I'm also slightly curious why that second error doesn't get through to my exception handler, and stick the application in an infinite loop of forward->exception->handle->forward->exception. Any thoughts are appreciated. Thanks, John
<<inline: image001.gif>>
------------------------------------------------------------------------------ uberSVN's rich system and user administration capabilities and model configuration take the hassle out of deploying and managing Subversion and the tools developers use with it. Learn more about uberSVN and get a free download at: http://p.sf.net/sfu/wandisco-dev2dev
_______________________________________________ Stripes-users mailing list Stripes-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/stripes-users