Bug 31659

Summary: [PATCH] Page context not fully populated for Exception if using app-wide error page
Product: Tomcat 5 Reporter: Roger Yates <roger42yates>
Component: JasperAssignee: Tomcat Developers Mailing List <dev>
Status: RESOLVED FIXED    
Severity: enhancement    
Priority: P3    
Version: 5.5.7   
Target Milestone: ---   
Hardware: PC   
OS: All   
Attachments: Patch against -r1.62
Alternative patch

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.