• 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

Custom Error Messages...

 
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
OK, I have been racking my brain on how to do this, I have searched high and low and I haven't found a solution to the problem. Is there a way with Tomcat to set up a custom error page when something goes wrong on a page? I can't seem to find anything on this or how to do it.
Thanks in advance.
Matt
 
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
That functionality is built in to the JSP spec. In your page directive you set an errorPage url with the (SURPRISE!) errorPage attribute. That URL points to a JSP page that has the attribute isErrorPage="true"
On that page you will have an automatic object named (SURPRISE!) exception. You can then output a stack trace or otherwise pull diagnostic information out of the exception thrown by your page....
This is all discussed in the JSP API documentation.
Any decent servlets and JSP book would have an example.
Bill
------------------
author of:
 
Matt Williams
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Great, but that doesn't solve the problem unless you add that tag in every page of the application. The application that we are developing has hundred of pages. Tomcat can't just have a setting in the config that will allow all errors to point to a specific page even if it doesn't have the error page set?
Matt
P.S. Not sure if the sarcasm is warrented here. I am sure that you have been a Java pro your entire life and never needed to ask for help. Very uncool.
 
Sheriff
Posts: 4313
Android IntelliJ IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
If your application is packaged in a WAR file (Web Application) you can specify error pages in your web.xml (this way you can cover ALL the pages in your app, plus its not tied to one particular app server):
From the Servlet 2.2 spec web.xml -->

Here's an example:

Hope that helps!

------------------
- Jessica Bradley
HP Bluestone
 
Matt Williams
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks Jessica,
That does help. I am checking it out right now.
Matt
 
I can't beleive you just said that. Now I need to calm down with this tiny ad:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic