jQuery in Action, 2nd edition*
The moose likes Web Component Certification (SCWCD/OCPJWCD) and the fly likes Cannot print exception message Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of OCM Java EE 6 Enterprise Architect Exam Guide this week in the OCMJEA forum!
JavaRanch » Java Forums » Certification » Web Component Certification (SCWCD/OCPJWCD)
Bookmark "Cannot print exception message" Watch "Cannot print exception message" New topic
Author

Cannot print exception message

Todd Farmer
Ranch Hand

Joined: May 28, 2004
Posts: 59
I'm working through the exception handling sections of HFS, and I'm not getting the results I am expecting. I have configured the following in web.xml:



I have a page that throws exceptions from the following code:



The /testJSP/matherrors.jsp page is configured as an error page:



I try to print out the exception message using the following EL:



When I invoke the error-throwing page, I am correctly routed to the exception page, but the exception message does not display at all.

Can anybody provide any suggestions on why this is happening? I am using Tomcat 5.0.

Thanks!

Todd Farmer
[ April 19, 2005: Message edited by: Todd Farmer ]
chowdary Thammineedi
Ranch Hand

Joined: Aug 16, 2004
Posts: 126
Hello Todd

I'm having the same problem too. This is my error page

<%@ page isErrorPage="true" isELIgnored="false" %>



and the result was this

The Exception using EL is :
The Exception using SCRIPTING is : null
The Exception using request attribute is : null
The Exception using request attribute is : java.lang.ArithmeticException: / by zero

Only the request attribute javax.servlet.error.exception is being set.

But when i went back to the page which throws the exception and added a page directive with the errorPage attribute then all four were working.

Tomcat version 5.5.7
chowdary Thammineedi
Ranch Hand

Joined: Aug 16, 2004
Posts: 126
Also when I put in this expression

${pageContext.errorData.throwable} in the error page

I noticed that the error data instance was set. (This is without having errorPage attribute in the throwing page).

The JSP 2.0 spec page 1-34 section JSP1.4.3 says this


A JSP is considered an Error Page if it sets the page directive�s isErrorPage
attribute to true. If a page has isErrorPage set to true, then the �exception� implicit
scripting language variable (see Table JSP.1-7) of that page is initialized.


Notice that it does not say it is a MUST.

Later in the paragraph it says


In addition, an ErrorData instance must be initialized based on the error
handler ServletRequest attributes defined by the Servlet specification, and made
available through the PageContext to the page. This has the effect of providing
easy access to the error information via the Expression Language. For example, an
Error Page can access the status code using the syntax ${pageContext.error-
Data.statusCode}.


Notice the MUST heremust
Todd Farmer
Ranch Hand

Joined: May 28, 2004
Posts: 59
Originally posted by chowdary Thammineedi:
Also when I put in this expression

${pageContext.errorData.throwable} in the error page

I noticed that the error data instance was set.


Well, that worked for me! I replaced:





with



I wonder why this doesn't match what is in HFS (page 461).

Thanks for the feedback!

Todd Farmer
chowdary Thammineedi
Ranch Hand

Joined: Aug 16, 2004
Posts: 126
Hello Todd

This is a known bug in Tomcat
Find details here.

http://issues.apache.org/bugzilla/show_bug.cgi?id=31659
[ April 21, 2005: Message edited by: chowdary Thammineedi ]
Todd Farmer
Ranch Hand

Joined: May 28, 2004
Posts: 59
Thanks! I think I'm going to have to spend some time looking through the Tomcat bug reports...

Todd Farmer
SCJP
SCWCD
MySQL Core
 
 
subject: Cannot print exception message