dcsimg
Is there a workaround for "bug" 1867?
1 posts in topic
Flat View  Flat View
TOPIC ACTIONS:
 

Posted By:   Michael_Duffy
Posted On:   Friday, May 30, 2003 11:29 AM

The JSP error page exception attribute not set from servlet when a ServletException is thrown. Craig McClanahan says the JSP spec only requires that attribute to be set if the exception is thrown by a JSP page. I'm using Tomcat 4.1.24 running on Windows 2000 and JDK 1.4.1. I tried adding an error-page to my web.xml that steered my app to a JSP whenever a javax.servlet.ServletException was thrown, but that didn't work. If I steer the app to the same JSP when error code 500 is encountered I get to see the page but I can't get any exception information out of it. Is there any workaround that I can use to get the exception message out to my error JSP? I don't want the stack t   More>>


The JSP error page exception attribute not set from servlet when a ServletException is thrown. Craig McClanahan says the JSP spec only requires that attribute to be set if the exception is thrown by a JSP page.




I'm using Tomcat 4.1.24 running on Windows 2000 and JDK 1.4.1.




I tried adding an error-page to my web.xml that steered my app to a JSP whenever a javax.servlet.ServletException was thrown, but that didn't work. If I steer the app to the same JSP when error code 500 is encountered I get to see the page but I can't get any exception information out of it.




Is there any workaround that I can use to get the exception message out to my error JSP? I don't want the stack trace, just enough of an explanation to give users something to say when they pick up the phone to call me. Thanks - MOD

   <<Less

Re: Is there a workaround for "bug" 1867?

Posted By:   Michael_Duffy  
Posted On:   Friday, June 6, 2003 10:59 AM


I'm answering my own question for posterity's sake.




I stopped doing a response.sendError in my servlet when an exception was caught. Instead, I have a block of code like this:





catch (Exception e)
{
servletContext.log(e.getMessage(), e);
request.setAttribute("javax.servlet.jsp.jspException", e);
String epage = "/error.jsp";
RequestDispatcher rd = request.getRequestDispatcher(epage);
rd.forward(request, response);
}




Setting the javax.servlet.jsp.jspException attribute in the request gets the value down to the JSP from the servlet.

About | Sitemap | Contact