• 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
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

printing exception object through jsp expressions.

 
Ranch Hand
Posts: 437
Oracle Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
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
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.
 
Ranch Hand
Posts: 689
Scala Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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: 437
Oracle Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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: 437
Oracle Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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: 437
Oracle Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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: 437
Oracle Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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 VI Editor Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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: 437
Oracle Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thankyou Sir.
 
Life just hasn't been the same since the volcano erupted and now the air is full of tiny ads.
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic