Customize Tomcat error page with error-page in web.xml 

Joined:
08/13/2009
Posts:
164

February 21, 2012 20:33:58    Last update: February 21, 2012 20:33:58
You can customize Tomcat error page with error code:
<error-page>
	<error-code>404</error-code>
	<location>/error/404.html</location>
 </error-page>

 <error-page>
	<error-code>500</error-code>
	<location>/error/500.html</location>
 </error-page>

or Java exception type:
<error-page>
	<exception-type>java.lang.Throwable</exception-type>
	<location>/error/500.html</location>
 </error-page>

Either error-code or exception-type is required, but not both. There's no way to aggregate error codes, such as:
<!-- This does not work! -->
<error-page>
    <error-code>500,503</error-code>
</error-page>

Customizing error pages is about the only way to suppress the default stack trace in Tomcat in case of an unhandled exception.
Share |
| Comment  | Tags