You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by Drew Cox <dr...@epredix.com> on 2002/02/20 02:27:07 UTC

RE: Problems accessing exception implicit object in error JSPs -Tomcat 4.0.2

Thanks for the incredibly quick response Craig, this clears it up for me.

We are trying to settle on 3.3a or 4.0.2 are a replacement for 3.1 for our
next release, this issue was forcing us down the 3.3a path.  Now, if only we
could sort out the issue with the use of multiple xerces.jars....(another
day).

<rant>
I must say, choosing the right error handling strategy is a little confusing
just reading the Servlet and JSP APIs.  Surely the spec's could align a
little better and *always* slave the "exception" implicit object to the
"javax.servlet.error.exception" request attribute if the "isErrorPage"
attribute is set?  They just drop the "javax.servlet.jsp.jspException"
attribute altogether and we'd be golden.
</rant>

Cheers
Drew


-----Original Message-----
From: Craig R. McClanahan [mailto:craigmcc@apache.org]
Sent: Tuesday, February 19, 2002 5:03 PM
To: Tomcat Users List
Subject: Re: Problems accessing exception implicit object in error JSPs
-Tomcat 4.0.2




On Tue, 19 Feb 2002, Drew Cox wrote:

> Date: Tue, 19 Feb 2002 16:49:00 -0800
> From: Drew Cox <dr...@epredix.com>
> Reply-To: Tomcat Users List <to...@jakarta.apache.org>
> To: Tomcat Users List <to...@jakarta.apache.org>
> Subject: Problems accessing exception implicit object in error JSPs -
>     Tomcat 4.0.2
>
> My apologies if this issue has been done to death, but I've done some
> searching on the archives but has not seen a definitive answer.
>
> We are using the "<error-page> <exception-type>" entries in the web.xml to
> direct all our web application exceptions to various error JSPs.  This is
> working.  These JSPs have the "<%@ page isErrorPage ="true" %>" directive
> set.
>
> In Tomcat 3.3a these pages have access to the "exception" implicit object.
> For the same webapp deployed in Tomcat 4.0.2 this variable is declared,
but
> null.  Is this a bug?
>

It's not a bug in 4.0.2 -- at best you could say that 3.3 is going above
and beyond what the spec requires.

> In the interim we are getting access to the exception from the
> "javax.servlet.error.exception" request attribute.  I also notice in the
JSP
> 1.2 API that a "javax.servlet.jsp.jspException" request attribute may also
> be available.  Which should I be using?  Our apps are a collection of JSPs
> and servlets, roughly conforming to the model-2 architecture (if its still
> called that).
>

The spec requirements are like this:

* Exceptions in a JSP page that declares an "errorPage" attribute
  are exposed -- to that error page -- as an implicit named "exception"

* Exceptions in a servlet (or a JSP page that does not declare an
  "errorPage" directive) are handled via the standard <error-page>
  declaration in your web.xml file, which exposes the actual exception
  as request attribute "javax.servlet.error.exception" (Servlet 2.3,
  Section 9.9.2).  Note that this attribute was new in 2.3, so isn't
  necessarily implemented by Tomcat 3.3.

Personally, I never use the JSP "errorPage" attribute -- I prefer to use
the <error-page> mechanism to handle all application exceptions, no matter
where they were caused.  The only practical difference is that you can't
declare different error page handlers for different source JSP pages, but
that has not been an issue for me.

> Cheers
> Drew Cox
>

Craig McClanahan


--
To unsubscribe:   <ma...@jakarta.apache.org>
For additional commands: <ma...@jakarta.apache.org>
Troubles with the list: <ma...@jakarta.apache.org>



--
To unsubscribe:   <ma...@jakarta.apache.org>
For additional commands: <ma...@jakarta.apache.org>
Troubles with the list: <ma...@jakarta.apache.org>