Win a copy of Five Lines of Code this week in the OO, Patterns, UML and Refactoring forum!
  • 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 all forums
this forum made possible by our volunteer staff, including ...
  • Campbell Ritchie
  • Bear Bibeault
  • Ron McLeod
  • Jeanne Boyarsky
  • Paul Clapham
  • Tim Cooke
  • Liutauras Vilda
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • fred rosenberger
  • salvin francis
  • Piet Souris
  • Frits Walraven
  • Carey Brown

Error pages

Ranch Hand
Posts: 39
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have the following:


<web-app xmlns:xsi=""; xmlns=""; xmlns:web=""; xsi:schemaLocation="" id="WebApp_ID" version="2.5">


<exception-type>java.lang.ArithmeticException </exception-type>



and i have this jsp:
<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "">;
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Insert title here</title>
You caused an ${pageContext.exception }

In HF book it states if the jsp does not have the page directive and attribute isErrorPage set to true it doesnt have the implicit exception object.

But when i hit the jsp that gives me an ArithimeticException it forwards to the error.jsp. In error.jsp it uses the implicit object and prints info about the exception. As i understood, it should not print anything since i dont have the exception implicit object. Can someone help me on this?

Posts: 23
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If you set isErrorPage = true , then you can directly access the 'exception' implicit variable.

here you are accessing the 'pageContext' implicit variable available to EL, which you can do in any page.

If you try to access 'exception' implicit variable here you will get an exception. It will work only if you set <%@ page isErrorPage = true %> in the page
Amar Nath Verma
Posts: 23
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
One correction:
If you use 'exception' implict variable without setting isErrorPage true, you will get a jsp compilation error
Don't get me started about those stupid light bulbs.
    Bookmark Topic Watch Topic
  • New Topic