tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Konrad Bernstein <bern...@gmx.net>
Subject Re: pageContext.getException() always null
Date Tue, 07 Jun 2005 14:26:18 GMT
Seems to me like a pure Tomcat-issue.
Downloaded and tested a couple of TC versions (5.0.28, 5.0.30 beta).
Same result: pageContext.getException() always returns null.

I then built Tomcat on my own (via
http://jakarta.apache.org/tomcat/tomcat-5.0-doc/build.xml)
and everything worked fine there.

Looking at the source of class PageContextImpl made clear, that
the version has changed. The new implementation of method getException()
now uses JspRuntimeLibrary.getThrowable(request) instead of
request.getAttribute(PageContext.EXCEPTION)

This comes down to returning the request attribute
"javax.servlet.error.exception" instead of "javax.servlet.jsp.jspException".

So, if you use code like

Throwable error = (Throwable)
request.getAttribute("javax.servlet.error.exception")
instead of
pageContext.getException()

you should be fine.

However, looks like a TC bug to me, that only occurs if you setup your
error pages by
the error-tag within web.xml (not by using the page directive
errorPage). pageContext.getException()
only returns what is saved under attribute
"javax.servlet.jsp.jspException". But this attribute is
not set, if you're throwing from a Servlet, for instance (as with Struts
etc.).

Have fun,
Konrad

---------------------------------------------------------------------
To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tomcat-user-help@jakarta.apache.org


Mime
View raw message