Sumit,

Am 2019-12-03 13:11, schrieb Sumit Bhardwaj:
Hi Experts,

We have a requirement from a customer, where in case of 404, where someone is putting an invalid url, instead of showing the default error, we should
be showing a custom message.

Is this possible?

I have searched and found couple of solutions similar to
https://stackoverflow.com/questions/27859626/tomcat-server-change-default-http-404


but these did not work, these work at the app level, but not globally on
tomcat level.

this can also be configured on the global web.xml. An alternative way would be a CustomErrorReportValve that can be configured on the Host-Element in server.xml.

<Host name="localhost" appBase="webapps" unpackWARs="false" autoDeploy="false" deployXML="true" errorReportValveClass="whatever.tomcat.valves.CustomErrorReportValve">

see: https://tomcat.apache.org/tomcat-8.5-doc/config/host.html#Common_Attributes -> errorReportValveClass

One link I found is https://aspiresoftware.in/blog/catalinatomcat-custom-error-report-valve-to-handle-errors-exceptions/

Best regards

Peter


e.g. if i have an app called myapp

http://<server address>/myapp/<invalid path> This  works and it gets
redirected to custom page

but

http://<server address>/<invalid App>, This does not work and 404 is shown,

Is there someway we can handle errors at global level on tomca.t

We are using tomcat 9.0.24.

Thanks for your help.

Best
Sumit Bhardwaj

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org
For additional commands, e-mail: users-h...@tomcat.apache.org

Reply via email to