• Post Reply Bookmark Topic Watch Topic
  • New Topic

isErrorPage="true" is not working properly

 
Jay Josh
Greenhorn
Posts: 16
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have an errorPage.jsp as shown below



They say to use the 'exception' object one should use page directive inside error page.



But whether I use it or not the page is executing properly and I could able to use pageContext.exception object. Even If I make isErrorPage="false" its working fine.

I dont know why its happening? Please help.
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 65519
105
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Perhaps I am misunderstand your question, but are you expecting the directive to cause an exception that you can display?
 
Jay Josh
Greenhorn
Posts: 16
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
No. They say if somebody need access to 'exception' object then one should use directive as true. But my question is I could display exception even without using directive or even using isErrorPage="false". What is the use of directive then?
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 65519
105
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The isErrorPage directive makes sure that the scripting variable exception is set in the page when used as an error page. This is only useful when using JSP 1.x and scriptlets (which you are correctly not using).

It has nothing at all to do with the JSTL and El and whether the exception is available on the page context.

Additionally (from the Spec):
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. 


See section JSP.1.4.2 of the JSP 2.2 Spec (or whatever version you are using) for more info.
 
Jay Josh
Greenhorn
Posts: 16
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What I am getting from your reply is that you are saying isErrorPage="true" directive is only useful while using scriplets but its presence doesn't make any sense while accessing exception object using EL? Hope I am getting it right.

Also where I got confused is, in the Head first Servlets and Jsp 2nd edition, they have mentioned that

"Note: the exception implicit object is available ONLY to error pages with an explicitly-defined page directive: <%@ page isErrorPage=”true” %>
In other words, configuring an error page in the DD is not enough to make the Container give that page the implicit exception object!"


And while giving this note they have used exception object using EL as ${pageContext.exception}. Please see the attached picture.



IsErrorPage.jpg
[Thumbnail for IsErrorPage.jpg]
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 65519
105
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Jay Josh wrote:What I am getting from your reply is that you are saying isErrorPage="true" directive is only useful while using scriplets but its presence doesn't make any sense while accessing exception object using EL? Hope I am getting it right.

No, see the section of the spec that I quoted. It also causes extra information to be added to the scopes.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!