Custom Error Pages — Apache Tomcat
if else there is a need for custom error pages to be created for Tomcat Application Server then follow below method
→create custom page at specified location
→edit web.xml
1.Create a 404.html page inside tomcat_home>webapps>ROOT>error folder with required content.
Get Rajesh’s stories in your inbox
Join Medium for free to get updates from this writer.
an example content can be:
<h2>Oops you are at the wrong location, please go back to home page</h2>
2.Now edit web.xml available inside tomcat_home>webapps>ROOT>WEB-INF to add following custom error code
<error-page>
<error-code>404</error-code>
<location>/error/404.html</location>
</error-page>
make sure the code comes inside <web-app> </web-app> TAGs of web.xml
Test the application:
start tomcat and access the home page with localhost:8080/hello and you should see the custom error page displayed.

![Linux [Ubuntu] on Windows 10](https://miro.medium.com/v2/resize:fit:1358/format:webp/1*59i_acAhaF6Za0DT-ZlSSQ.jpeg)





