Tomcat Error Page

Tomcat Error Page

How to handle error page

  • server.xml
  • web.xml
  • errorReportValveClass

server.xml

Editting….

web.xml

We have 2 web.xml. One is global web.xml, the other is WEB-INF/web.xml(application)
Both are fine, but I recommend application web.xml

Add error-page element

<error-page>
  <error-code>404</error-code>
  <location>/error/404.html</location>
</error-page>

If you want to cover every error

<error-page>
  <location>/error/error.html</location>
</error-page>

errorReportValveClass

errorReportValveClass is error page handler class identifier in server.xml

errorReportValveClass=""

This means that error handler skips handling error.