Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Tomcat server, change default HTTP 404?

I am using tomcat and I would like, whenever I go to a direction that is not handled by a servlet, do other stuff insead of showing the default error:

type Status report

message /test

description The requested resource is not available.

Where can I handle this¿?

Thank you in advance

like image 762
aDoN Avatar asked Jan 09 '15 11:01

aDoN


Video Answer


1 Answers

Since Tomcat 9 there is different error handling configuration.

You have to:

  • create simple html error page
  • save it in some directory(for example webapps/ROOT/error_page.html)
  • add valve configuration to server.xml in Host part.
<Valve className="org.apache.catalina.valves.ErrorReportValve" errorCode.404="webapps/ROOT/error_page.html" errorCode.0="webapps/ROOT/error_page.html" showReport="false" showServerInfo="false" />

Please refer: https://stackoverflow.com/a/55702749/2532710 or Tomcat documentation: https://tomcat.apache.org/tomcat-9.0-doc/config/valve.html#Error_Report_Valve

like image 92
Grzegorz Jasiński Avatar answered Oct 06 '22 13:10

Grzegorz Jasiński