Much thanks to Jayson and Hans for their replies.  It all makes sense now.

And when they're published, I'll be picking up copies of both of your new
books to say thanks. :) I'm looking forward to their release.

Jay

 > -----Original Message-----
 > From: Jayson Falkner [mailto:[EMAIL PROTECTED]]
 > Sent: Monday, July 15, 2002 8:30 AM
 > To: [EMAIL PROTECTED]
 > Subject: Re: error-page vs. errorPage
 >
 >
 > Hi Jay,
 >
 > I think this is an issue which was resolved with JSP 2.0. The
 > problem is
 > that an exception passed via web.xml uses the servlet spec, i.e. the
 > scoped variables set are :
 >
 > javax.servlet.error.status_code java.lang.Integer
 > javax.servlet.error.exception_type java.lang.Class
 > javax.servlet.error.message java.lang.String
 > javax.servlet.error.exception java.lang.Throwable
 > javax.servlet.error.request_uri java.lang.String
 > javax.servlet.error.servlet_name java.lang.String
 >
 > And the JSP 1.2 specs uses:
 >
 > javax.servlet.jsp.jspException
 >
 > So when you use web.xml for error handling (using JSP
 > 1.2/Servlets 2.3)
 > you get a NullPointerException because you are trying to access
 > "javax.servlet.jsp.jspException" (i.e. exception) when it
 > doesn't exist,
 > "javax.servlet.error.exception java.lang.Throwable" exists.
 >
 > To solve the problem now, try something like:
 >
 > <%
 >   if (exception == null) {
 >     exception = (java.lang.Throwable)
 > request.getAttribute("javax.servlet.error.exception
 > java.lang.Throwable"); //remove line-wrap...
 >   }
 > %>
 >
 > And you should be set. FYI, JSP 2.0 should do this automatically for
 > you, however, officially check the spec ;)
 >
 > You should keep an eye on http://www.jspbook.com - Kevin Jones and I
 > have been working hard on a JSP 2.0 and Servlet 2.4 book which will be
 > out to compliment the upcoming specs. We cover this topic
 > along with the
 > million other JSP/Servlet things you should know about!
 >
 > Cheers,
 >
 > Jayson Falkner
 > [EMAIL PROTECTED]
 >
 >
 > Jay Burgess wrote:
 > > (I tried this question on the Tomcat list, and got no
 > response.  Maybe it's
 > > more of a JSP question? Thanks in advance.)
 > >
 > >> Can someone explain the relationship between the
 > <error-page> element in
 > >> my webapp's WEB.XML versus the "errorPage" attribute of the page
 > >> directive
 > >> within a JSP?  I'm trying to create a single error page
 > that handles any
 > >> exceptions generated by the JSPs within my webapp, without
 > having to name
 > >> the error page in every JSP.
 > >>
 > >> To start with, I added the following to my web app's WEB.XML to
 > >> indicate a
 > >> "catch all" error page for the app:
 > >>
 > >>     <error-page>
 > >>         <exception-type>java.lang.Exception</exception-type>
 > >>         <location>/error.jsp</location>
 > >>     </error-page>
 > >>
 > >> I also marked ERROR.JSP as an error page by including the
 > following at
 > >> the
 > >> top (note the isErrorPage attribute):
 > >>
 > >>     <%@ page contentType="text/html; charset=ISO-8859-1"
 > buffer="64kb"
 > >> isErrorPage="true" %>
 > >>
 > >> Unfortunately, when trying to access the "exception"
 > object in ERROR.JSP,
 > >> I get a NullPointerException, as though it doesn't exist.
 > >>
 > >> Since I thought this should work, I must be missing
 > something?  (I'm
 > >> using
 > >> Tomcat 4.0.4, by the way.)
 > >>
 > >> Thanks.
 > >>
 > >> Jay
 > >
 > >
 > >
 > > -- Jay Burgess [[EMAIL PROTECTED]]
 > >    Digital Archaeology Corporation
 > >    (913) 438-9444 x154
 > >

===========================================================================
To unsubscribe: mailto [EMAIL PROTECTED] with body: "signoff JSP-INTEREST".
For digest: mailto [EMAIL PROTECTED] with body: "set JSP-INTEREST DIGEST".
Some relevant FAQs on JSP/Servlets can be found at:

 http://archives.java.sun.com/jsp-interest.html
 http://java.sun.com/products/jsp/faq.html
 http://www.esperanto.org.nz/jsp/jspfaq.jsp
 http://www.jguru.com/faq/index.jsp
 http://www.jspinsider.com

Reply via email to