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:
1 2 3 4 5 6 7 8 |
public class ErrorSuppressorValve extends ErrorReportValve { protected void report(Request request, Response response, Throwable throwable) { // Override the default behavior by doing nothing } } |
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.