Bug 31659 - [PATCH] Page context not fully populated for Exception if using app-wide error page
Summary: [PATCH] Page context not fully populated for Exception if using app-wide erro...
Status: RESOLVED FIXED
Alias: None
Product: Tomcat 5
Classification: Unclassified
Component: Jasper (show other bugs)
Version: 5.5.7
Hardware: PC All
: P3 enhancement with 2 votes (vote)
Target Milestone: ---
Assignee: Tomcat Developers Mailing List
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2004-10-12 02:43 UTC by Roger Yates
Modified: 2005-02-25 09:49 UTC (History)
0 users



Attachments
Patch against -r1.62 (770 bytes, patch)
2004-12-25 23:00 UTC, Torsten Fohrer
Details | Diff
Alternative patch (1.44 KB, patch)
2005-02-25 18:44 UTC, Jan Luehe
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Roger Yates 2004-10-12 02:43:18 UTC
No exception is displayed when using the EL expression 
${pageContext.exception} on an application-wide error page. (If using a page-
specific error page, the details are displayed correctly - even using a copy 
of the same page!).

EL *is* being evaluated since it is possible to display the exception by using 
the following EL expression: ${pageContext.errorData.throwable}

Here's what I'm using:
In the DD:
	<error-page>
		<exception-type>java.lang.NullPointerException</exception-type>
		<location>/nullErrorPage.jsp</location>
	</error-page>

The error page nullErrorPage.jsp:
<%@ page isErrorPage="true"%>
<html><body>
You caused a NULL pointer exception! :( <br>
Exception type: ${pageContext.exception} <br>
Errordata: ${pageContext.errorData.throwable} <br>
</body></html>

and the request page:
<html><body>
Trying something naughty...: <br>
<% String s=null ; %>
<% int x=s.length() ; %>
</body></html>

By adding the line: <%@ page errorPage="/nullErrorPage.jsp" %>
to the request page, the exception details will be displayed correctly, so 
something is happening (or rather not happening) for a DD-specified error page.
Comment 1 Yoav Shapira 2004-11-17 14:55:08 UTC
If you want this addressed in the near future, please submit a proposed patch.
Comment 2 Torsten Fohrer 2004-12-25 23:00:10 UTC
Created attachment 13843 [details]
Patch against -r1.62
Comment 3 Torsten Fohrer 2004-12-25 23:01:16 UTC
Patch with extended PageContextImpl.getException() to look also for
"javax.servlet.error.exception".
Comment 4 Jan Luehe 2005-02-25 18:44:32 UTC
Created attachment 14363 [details]
Alternative patch

Alternative patch used to fix the issue.
This patch leverages JspRuntimeLibrary.getThrowable(), which already checks for
"javax.servlet.error.exception" and "javax.servlet.jsp.jspException", in this
order.