• 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

tomcat 5 and error page

 
Ranch Hand
Posts: 185
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Sheriff
Posts: 67746
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
"It doesn't work" is a completely useless statement. What exactly is happening?
 
Author and all-around good cowpoke
Posts: 13078
6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
Posts: 13078
6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
For my next feat, I will require a volunteer from the audience! Perhaps this tiny ad?
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic