Alt. Error Page for Tomcat

How to add custom error pages in Tomcat 9?

We are going added two custom error pages one is 404 and one all the other errors for tomcat 9. we’ll start with creating error pages and added it to webapps directory of tomcat.

I have added two pages 404.html and error.html under webapps/error

404 Page

Now we need to edit server.xml and added following code under Host tag

<Valve className=”org.apache.catalina.valves.ErrorReportValve” showReport=”false” showServerInfo=”false” errorCode.404=”webapps/error/404.html” errorCode.0=”webapps/error/error.html” />

Now start the tomcat and enjoy your new error pages in action.

--

--