Where are Tomcat's default error pages located or how can I customize them? I wish to beautify and change the look and feel of current error pages of Tomcat.
The default error pages are created by Java code:
ErrorReportValve
: see source code,LocalStrings_<locale>.properties
files of the same package: see the English version.If you want to replace them with static content, you need to:
$CATALINA_BASE/errors/404.html
,ErrorReportValve
accordingly:
<Host>
<Valve className="org.apache.catalina.valves.ErrorReportValve"
errorCode.404="errors/404.html" />
</Host>
External resources in error pages may cause problem: you must check that no security constraints are defined on those resources.
Edit: This of course works if the web applications don't define any error pages. If a custom error page exists in the application it has priority over the error pages defined in the ErrorReportValve
.