Sharing the Point

Office 365, SharePoint, Project Server – Support Blog

How to Display Custom Error Page on Tomcat 6

Posted by Ashraf on December 3, 2010

If you are Unhappy with the default error pages that come with Tomcat then You can define your own custom error pages in your web.xml file after the following tag:

<welcome-file-list>

<welcome-file>index.html</welcome-file>

</welcome-file-list>

In the example shown below, i define 2 html pages — web_server_error_500.html and file_not_found_404.html which will be displayed when the server encounters an error 500 or an error 404 respectively. Put your html files on tomcat6.0/webapps/Root folder.  And add this code on web.xml file.

<error-page>

<error-code>500</error-code>

<location>/web_server_error_500.html</location>

</error-page>

<error-page>

<error-code>404</error-code>

<location>/file_not_found_404.html</location>

</error-page>

Please be aware that the order of the tags for the web.xml file is very important. If the order in your web.xml file is incorrect, Tomcat will output errors on startup.

And for Internet Explorer users be sure you have enabled “Show custom error pages” from Internet Options>Advanced tab.

Advertisements

Sorry, the comment form is closed at this time.

 
%d bloggers like this: