• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • Liutauras Vilda
  • Jeanne Boyarsky
  • paul wheaton
Sheriffs:
  • Ron McLeod
  • Devaka Cooray
  • Henry Wong
Saloon Keepers:
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Tim Moores
  • Mikalai Zaikin
Bartenders:
  • Frits Walraven

Page 461

 
Ranch Hand
Posts: 38
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Sheriff
Posts: 14691
16
Eclipse IDE VI Editor Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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.
 
Ranch Hand
Posts: 30
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Christophe Verré
Sheriff
Posts: 14691
16
Eclipse IDE VI Editor Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
snakes are really good at eating slugs. And you wouldn't think it, but so are tiny ads:
Gift giving made easy with the permaculture playing cards
https://coderanch.com/t/777758/Gift-giving-easy-permaculture-playing
reply
    Bookmark Topic Watch Topic
  • New Topic