caot
caot

Reputation: 3328

How to redirect "HTTP Status 404 – Not Found" to an error information page in tomcat?

In tomcat, an invalid link can throw a HTTP Status 404 – Not Found as follows.

enter image description here

How to configure tomcat to redirect it to an error information page, such as The request is invalid! if such a case happens?

Upvotes: 2

Views: 1946

Answers (1)

Mahesh
Mahesh

Reputation: 78

Need to add the following to file ROOT/WEB-INF/web.xml

<error-page>
  <error-code>404</error-code>
  <location>/yourLocationToredirect</location>
</error-page>

Also write a message in any html or jsp and add this page as redirect location

The following link discussed the same question https://serverfault.com/questions/254102/custom-error-pages-on-apache-tomcat

Upvotes: 2

Related Questions