A variation on the above approach is to make your custom valve class extend Tomcat's
org.apache.catalina.valves.ErrorReportValve and just override the
report method. Copy the
existing implementation of this method from the Tomcat source then adapt it to write your custom error page HTML as desired (e.g. excluding the container description and exception stack trace for security-sensitive environments).
Finally, configure this valve on the host as described previously, e.g.