View Single Post
Old 04-26-2004, 11:32 AM   #3 (permalink)
technobard
Centurion Nova Prime
 
technobard's Avatar
 
Join Date: May 2002
Location: Oak Park, IL (USA)
Posts: 285
technobard is on a distinguished road
If the failure occurs while a jsp is accessing the package as a bean, I believe you can use
Code:
<%= exception.getMessage() %>
To get this to work, however, you have to know that an error occurred in the jsp page. You can use a page directive to identify an errorpage that the code branches to if it hits an error, and then from the errorpage, you can display the exception message. Note: isErrorPage="true" allows the page to access the "exception" object from the prior jsp page.

Code:
<%@ page errorPage="errorpage.jsp" %>  //in original jsp file
...

//Contents of errorpage.jsp
<%@ page isErrorPage="true" %>
<html>
<body>
The following was an exception generated by....
<blockquote>
<%= exception.getMessage() %>
</blockquote>
</body>
</html>
This comes more or less from O'Reilly's "JavaServer Pages" book. Good stuff.
technobard is offline   Reply With Quote