Suppressing Tomcat error messages for all applications on a host

Sometimes I write web applications for Tomcat where I don’t want to report any errors beyond the HTTP status code. The quickest method for disabling those messages is configuring a Valve on the host section of the server.xml configuration file.

If you subclass the org.apache.catalina.valves.ErrorReportValve class (it’s in your Tomcat’s lib/catalina.jar) and override the report method like this:

The client still receives the HTTP status code and anything already buffered, but it hides all of the automatically generated Tomcat error information.

To install it, just JAR up the class and put it in your Tomcat’s lib folder, then add the errorReportValveClass attribute to your Tomcat’s server.xml file.

Leave a Reply

Your email address will not be published. Required fields are marked *