aspose file tools*
The moose likes Web Component Certification (SCWCD/OCPJWCD) and the fly likes printing exception object through jsp expressions. Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Certification » Web Component Certification (SCWCD/OCPJWCD)
Bookmark "printing exception object through jsp expressions." Watch "printing exception object through jsp expressions." New topic
Author

printing exception object through jsp expressions.

Chinmaya Chowdary
Ranch Hand

Joined: Apr 21, 2008
Posts: 432
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

Joined: Nov 24, 2005
Posts: 14687
    
  16

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.


[My Blog]
All roads lead to JavaRanch
Nishan Patel
Ranch Hand

Joined: Sep 07, 2008
Posts: 686


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,.....



Thanks, Nishan Patel
SCJP 1.5, SCWCD 1.5, OCPJWSD Java Developer,My Blog
Chinmaya Chowdary
Ranch Hand

Joined: Apr 21, 2008
Posts: 432
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

Joined: Apr 21, 2008
Posts: 432
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

Joined: Apr 21, 2008
Posts: 432
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

Joined: Apr 21, 2008
Posts: 432
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

Joined: Nov 24, 2005
Posts: 14687
    
  16

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

Joined: Apr 21, 2008
Posts: 432
Thankyou Sir.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: printing exception object through jsp expressions.