Custom Error Pages — Apache Tomcat

Rajesh
1 min readMay 17, 2019

--

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.

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.

Sign up to discover human stories that deepen your understanding of the world.

Free

Distraction-free reading. No ads.

Organize your knowledge with lists and highlights.

Tell your story. Find your audience.

Membership

Read member-only stories

Support writers you read most

Earn money for your writing

Listen to audio narrations

Read offline with the Medium app

--

--

Rajesh
Rajesh

No responses yet

Write a response