Mark,
Peter Kreuser >>> Am 03.12.2019 um 14:31 schrieb Mark Thomas <ma...@apache.org>: >> 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. Wouldn’t the global web.xml provide sort of the same solution - if it‘s really Sumit‘s intention to provide a custom 404 page only, for all apps? The Root-context approach may not work, if you hit a bad request/400, right? > 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 That‘s neat! It‘s not available in 8.5 though, that‘s why I used a CustomErrorReportValve until now. good to now, that will indeed remove complexity, as I‘d always have to deploy a global lib. Peter > Mark > > --------------------------------------------------------------------- > To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org > For additional commands, e-mail: users-h...@tomcat.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org For additional commands, e-mail: users-h...@tomcat.apache.org