On 03/12/2019 12:50, logo wrote: > 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.
No, it can't. conf/web.xml provides defaults for web applications, not global settings. > An alternative way > would be a CustomErrorReportValve that can be configured on the > Host-Element in server.xml. It would but, that is an overly complex solution. There are two better - in my view - options. 1. Deploy a ROOT web application with appropriate error page configuration. This will catch all URLs that aren't mapped to any other deployed applications. 2. Use errorCode.0="..." and/or exceptionType.java.lang.Throwable="..." attributes of the ErrorReportValve to define static web pages for those errors. http://tomcat.apache.org/tomcat-9.0-doc/config/valve.html#Error_Report_Valve/Attributes Mark --------------------------------------------------------------------- To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org For additional commands, e-mail: users-h...@tomcat.apache.org