tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Glen Mazza <>
Subject Re: Best practice for Capturing JSP Errors
Date Fri, 03 Feb 2006 03:57:27 GMT
Mott Leroy wrote:

> I am on Tomcat 5.0.x
> I am familiar with a couple ways to capture errors that occur on the JSP 
> side. One way is to use the error page tag:
> <%@ page errorPage="MyErrorPage.jsp" %>

Chapter 10 on exception handling, Beginning JavaServer Pages (Wrox 
Books, 2005), I think would be helpful for you here.

I think (am unsure) you can make your error page the same as the page 
that created the error (by adding another page directive <%@page 
isErrorPage="true" %> to the same page).  This way, by checking if the 
${pagecontext.exception} property is populated (indicating that this 
page was activated *not* as a non-exception first activation but as an 
exception-based second or third activation), you can then add error 
messages to the JSP page.

> And another is to define the error page in your web.xml:
> <error-page>
>      <error-code>500</error-code>
>       <location>/myPage.jsp</location>
> </error-page>

I would save these for generic HTTP error codes, or generic Java 
exceptions (NullPointerErrors, ClassCastExceptions, perhaps), things are 
more likely the result of errors in coding than in user entry, and 
something the user cannot really recover from.

Also, the JSTL <c:catch var="..."/> action may be something to look at 
here, to keep runtime/coding errors handled within the JSP pages, 
without needing to forward to a generic error page.


To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message