• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

printing exception object through jsp expressions.

 
Chinmaya Chowdary
Ranch Hand
Posts: 432
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi, I am using tomcat5.5 and I am not able to print exception object through jsp expressions<%= %>. Can anyone please tell me, how to print exception object through jsp expressions . Thankyou.
 
Christophe Verré
Sheriff
Posts: 14691
16
Eclipse IDE Ubuntu VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The exception object is available only if you have declared the page as being an error page, via the isErrorPage attribute of the page directive.
 
Nishan Patel
Ranch Hand
Posts: 689
Eclipse IDE Java Scala
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Hi,

The only way to get exception object you have to declare <%@ page isErrorPage="true" %>

That means only official error page makes exception object available at your jsp page,.....


 
Chinmaya Chowdary
Ranch Hand
Posts: 432
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks for your reply. I have used page directive that says <%@ page isErrorPage="ture" %> and I am not able to print exception object, throuh jsp expressions. Thankyou.
 
Chinmaya Chowdary
Ranch Hand
Posts: 432
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Nishan Patel wrote:
Hi,

The only way to get exception object you have to declare <%@ page isErrorPage="true" %>

That means only official error page makes exception object available at your jsp page,.....





Thankyou, Nishan. It's working.
 
Chinmaya Chowdary
Ranch Hand
Posts: 432
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Christophe Verré wrote:The exception object is available only if you have declared the page as being an error page, via the isErrorPage attribute of the page directive.


Thankyou Christophe. My next question is, without declaring <%@ page isErrorPage="true" %>, we can print the exeption object through EL ${pageContext.exception}. Why it is not possible with jsp expressions<%= %>?
 
Chinmaya Chowdary
Ranch Hand
Posts: 432
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Suppose, I have a page that is not specified with <%@ page errorPage=" " %>, if any exception occurs, the container chooses the DD to find the correct error page. In that error page(the page that is specified in DD<location>?</location>),if I specify<%@ page isErrorPage="true" %>, I can print the exception object through jsp expression<%= exception %>and EL ${pageContext.exception}. If I didn't specify the directive or isErrorPage="false", I can print the exception object through EL ${pageContext.exception}, but not with expression <%= exception %>. What is the reason? Thankyou.
 
Christophe Verré
Sheriff
Posts: 14691
16
Eclipse IDE Ubuntu VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
When the container translates your JSP into a servlet, it will declare the "exception" variable only if the isErrorPage attribute is set to true. That's why you can't access the variable if the attribute is not set to true, because it doesn't even exist in the servlet !

However, the pageContext implicit attribute is always accessible from EL, that's why you can always call ${pageContext.exception}.
 
Chinmaya Chowdary
Ranch Hand
Posts: 432
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thankyou Sir.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic