Error Handling In Jsp Using Web.xml
▼ JSP Tutorial JSP Introduction Life cycle of JSP JSP API JSP in Eclipse JSP scripting elements JSP scriptlet tag JSP expression tag JSP declaration tag 9 Implicit Objects JSP Request JSP Response JSP Config JSP Application JSP Session JSP PageContext JSP Page JSP Exception JSP Directive Elements JSP page directive JSP include directive JSP taglib directive JSP Exception Action Elements jsp:forward jsp:include Java Bean class jsp:useBean set & getProperty Displaying applet in JSP Expression Language MVC in JSP JSTL JSP Custom tags Example of Custom Tag Attributes Iteration Custom URI JSP Pagination JSP Pagination Example JSP CRUD JSP CRUD Example Development in JSP Registration Form Login Form Uploading File Downloading File Interview Questions JSP Quiz next>> < element in web.xml file Example of exception handling in jsp by the elements of page directive In this case, you must define and create a page to handle the exceptions, as in the error.jsp page. The pages where may occur exception, define the errorPage attribute of page directive, as in the process.jsp page. There are 3 files: index.jsp for input values process.jsp for dividing the two numbers and displaying the result error.jsp for handling the exception index.jsp
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 http://stackoverflow.com/questions/7066192/how-to-specify-the-default-error-page-in-web-xml Learn more about Stack Overflow the company Business Learn more about hiring developers or http://www.ibm.com/support/knowledgecenter/SSZLC2_8.0.0/com.ibm.commerce.developer.doc/concepts/csdjsperror.htm 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? error handling 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 error handling in 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,084195895 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. 401 /general-error.html 403 /ge