Home > error page > error page in web.xml

Error Page In Web.xml

here for a quick overview of the site Help Center Detailed answers to any questions you might have Meta Discuss the workings and policies of this site About Us Learn more about Stack Overflow the company Business Learn more about hiring developers or posting ads with us Stack Overflow Questions Jobs Documentation Tags Users Badges Ask Question x Dismiss Join the Stack Overflow Community Stack Overflow is a community of 4.7 million programmers, just like you, helping each other. Join them; it only takes a minute: Sign up How to specify the default error page in web.xml? up vote 85 down vote favorite 37 I am using element in web.xml to specify the friendly error page when user encounters a certain error such as error with code of 404: 404 /Error404.html However, I want that if the user does not meet any error code specified in , he or she should see a default error page. How can I do that using the element in the web.xml? java servlets tomcat6 web.xml custom-error-pages share|improve this question edited Sep 18 '14 at 14:42 Jayy 1,59521525 asked Aug 15 '11 at 14:34 ipkiss 4,089195895 2 What servletcontainer are you using/targeting and what servlet version is your web.xml declared to? There's only since Servlet 3.0 an easy way. –BalusC Aug 15 '11 at 14:44 I am using Tomcat 6, servlet 2.5 –ipkiss Aug 15 '11 at 14:49 add a comment| 2 Answers 2 active oldest votes up vote 161 down vote accepted On Servlet 3.0 or newer you could just specify /general-error.html But as you're still on Servlet 2.5, there's no other way than specifying every common HTTP error individually. You need to figure which HTTP errors the enduser could possibly face. On a barebones webapp with for example the usage of HTTP authentication, having a disabled directory listing, using custom servlets and code which can possibly throw unhandled exceptions or does not have all methods implemented, then you'd like to set it for HTTP errors 401, 403, 500 and 503 respectively.