Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

tomcat 5 and error page

 
danny liu
Ranch Hand
Posts: 185
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Pie
Posts: 64700
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
"It doesn't work" is a completely useless statement. What exactly is happening?
 
William Brogden
Author and all-around good cowpoke
Rancher
Posts: 13058
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 185
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
"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
Posts: 13058
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 185
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic