This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
The moose likes Web Component Certification (SCWCD/OCPJWCD) and the fly likes Page 461 Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Certification » Web Component Certification (SCWCD/OCPJWCD)
Bookmark "Page 461" Watch "Page 461" New topic
Author

Page 461

Giri Thava
Ranch Hand

Joined: Jun 22, 2006
Posts: 38
Page 461 says that the exception implicit object is available
only to error pages with an explicitly-defined page directive:
<%@ page isErrorPage="true" %>

However, in practice the implicit exception object is available to
the following code (errorPage.jsp):
<html>
<body>
${pageContext.exception}
</body>
</html>

And it is not avaolable to the following code (errorPage.jsp):
<html>
<body>
<%
out.print(exception.getMessage());
%>
</body>
</html>

The page that throws the exception is, badPage.jsp:
<%@ page errorPage="errorPage.jsp" %>
<html>
<body>
<%
int x = 10/0;
%>
</body>
</html>

Please explain me this problem. I am using Tomcat 5 with IE 6.
I searched the forum before posting this, but I cannot find anything useful.

Advance thanks.
Christophe Verré
Sheriff

Joined: Nov 24, 2005
Posts: 14687
    
  16


You are not using the exception implicit object here. What you're doing is access the exception property of the PageContext. The
container will call PageContext#getException, which, like any methods, will always be available. What the book is talking about is the exception implicit object, which you can access like this :

This object is only available to pages which have their isErrorPage attribute set to true.


[My Blog]
All roads lead to JavaRanch
Lavanya Mothilal
Ranch Hand

Joined: Dec 27, 2007
Posts: 30
Hi Christophe ,

EL does not have 'exception' as an implicit object. The only way to get the exception object is to go through the pageContext implicit object. So even if a jsp page is declared as an error page (using isErrorPage="true"), ${exception} will not work. Correct me if i am wrong.


Thanks,<br />Lavanya
Christophe Verré
Sheriff

Joined: Nov 24, 2005
Posts: 14687
    
  16

Oops, that's right, thanks for correcting. This implicit object can be accessed via a scriptlet

See Table JSP.1-7 in the JSP Specification for more.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Page 461
 
Similar Threads
How to get exception object on error page with EL?
designing error pages
problem while declaring error page
Unable to navigate to the error page
pageContext.exception is not executing