File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Tomcat and the fly likes Error handling in Tomcat Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Products » Tomcat
Bookmark "Error handling in Tomcat" Watch "Error handling in Tomcat" New topic

Error handling in Tomcat

Prakash Dwivedi
Ranch Hand

Joined: Sep 28, 2002
Posts: 452
How can i hadle errors in tomcat. for example if tomcat could not find a file it simply displays Internal Server Error 500, what i want is it should be directed to my error page, where i can display better message.

Prakash Dwivedi (SCJP2, SCWCD, SCBCD)
"Failure is not when you fall down, Its only when you don't get up again"
Dhananjay Inamdar
Ranch Hand

Joined: Jan 27, 2003
Posts: 130
if your application uses the JSP page then do the following things to display the your own message insted of the tomcat's.
1) Define your own page with any name(say ErrorDisplayer.jsp), but in the page directive make the isErrorPage= "True"
2) In this page take the error object and diplay the message with the help of methods of this object.
3) In all other remaining pages (say ErrorClient.jsp) add the page directive at the top and mention this pages relative url in the "errorPage" attribute.

Now when you will access the ErrorClient.jsp from the brower and error comes then control is transfered to the ErrorDisplayer.jsp page. Here in this page you have your own message which will get displayed on the brower insted of tomcat's message.
There is one more way also but it is very basic. There is one setting in the internet explorer to display a user friendly message. WHich will wrap ups the system error and display littile bit understandable message.
Check the upper one and let us know.

Just like you, struggeling to get the right solutions!<br /> <br />Sun Certified Java Programmer 1.5<br /> <br />Target - SCWCD
I agree. Here's the link:
subject: Error handling in Tomcat
It's not a secret anymore!