File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes JSP and the fly likes tomcat 5 and error page Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » JSP
Bookmark "tomcat 5 and error page" Watch "tomcat 5 and error page" New topic
Author

tomcat 5 and error page

danny liu
Ranch Hand

Joined: Jan 22, 2004
Posts: 185
Hi all:
When I used tomcat 5, I meet a wierd problem.
What I wanna do is to direct all errors to one shared error page. I don't like to add
a directive <%@ page errorPage="xxx" %>, so I add an error page entry in web.xml.
<error-page>
<exception-type>java.lang.Exception</exception-type>
<location>/error.jsp</location>
</error-page>
The error.jsp has a directive <%@ page isErrorPage="true" %>
But it doesn't work.
I also tried the error status code:
<error-page>
<error-code>404</error-code>
<location>/404.jsp</location>
</error-page>
It doesn't work either.
Can anyone give an idea?
Thanks.
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61201
    
  66

"It doesn't work" is a completely useless statement. What exactly is happening?


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
William Brogden
Author and all-around good cowpoke
Rancher

Joined: Mar 22, 2000
Posts: 12781
    
    5
I think you are trying to mix up two separate error handling mechanisms.
The error.jsp will be trying to find the exception according to the JSP mechanism but you are calling it by the general servlet mechanism.
I don't like to add a directive <%@ page errorPage="xxx" %>

Why not? Its just cut and paste.
Bill
danny liu
Ranch Hand

Joined: Jan 22, 2004
Posts: 185
"It doesn't work" is a completely useless statement. What exactly is happening?

That means a default message comes out with the exception message or "page cannot be found". It is not my customized return.
Why not? Its just cut and paste.

Bill, I just wanna try every potential functionality.
I have read messages about tomcat. Is this an internal bug of Tomcat 5?
Thanks.
Dan
William Brogden
Author and all-around good cowpoke
Rancher

Joined: Mar 22, 2000
Posts: 12781
    
    5
Is it a bug? No - like I said, there are two separate mechanisms.
In the JSP API documentation we find that a JSP error page expects to find a thrown exception in the forwarded request as an attribute attached to the request as "javax.servlet.jsp.jspException" - which is automatically provided as the "exception" on your JSP errorPage.
Bill
danny liu
Ranch Hand

Joined: Jan 22, 2004
Posts: 185
Bill:
Is it a bug? No - like I said, there are two separate mechanisms.
Correct, one in web.xml, one in page directive.
In the JSP API documentation we find that a JSP error page expects to find a thrown exception in the forwarded request as an attribute attached to the request as "javax.servlet.jsp.jspException" - which is automatically provided as the "exception" on your JSP errorPage.
Thank you for sharing idea with us.
My question is:
Have you tried the first approach (i.e., using web.xml)?
If you did, what container you used?
Thanks.
Dan
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: tomcat 5 and error page