Error Page Configuration 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 Servlets - Life Cycle Servlets - Examples Servlets - Form Data Servlets - Client Request Servlets - Server Response Servlets - Http Codes Servlets - Writing Filters Servlets - Exceptions Servlets - Cookies Handling Servlets - Session Tracking Servlets - Database Access Servlets - File Uploading Servlets - Handling Date Servlets - Page Redirect Servlets - Hits Counter Servlets - Auto Refresh Servlets - Sending Email Servlets - Packaging Servlets http://stackoverflow.com/questions/7066192/how-to-specify-the-default-error-page-in-web-xml - Debugging Servlets - Internationalization Servlet Useful Resources Servlets - Questions and Answers Servlets - Quick Guide Servlets - Useful Resources Servlets - Discussion Selected Reading Developer's Best Practices Questions and Answers Effective Resume Writing HR Interview Questions Computer Glossary Who is Who Servlets - Exception Handling Advertisements Previous Page Next Page http://www.tutorialspoint.com/servlets/servlets-exception-handling.htm When a servlet throws an exception, the web container searches the configurations in web.xml that use the exception-type element for a match with the thrown exception type. You would have to use the error-page element in web.xml to specify the invocation of servlets in response to certain exceptions or HTTP status codes. web.xml Configuration: Consider, you have an ErrorHandler servlet which would be called whenever there is any defined exception or error. Following would be the entry created in web.xml. Tutorial Categories: Ajax (1)Ant (16)Apache Web Server (8)Bioinformatics (10)Cascading Style Sheets (47)Classes and Objects (14)Database http://www.avajava.com/tutorials/lessons/how-do-i-create-a-jsp-error-page-to-handle-exceptions.html (13)Design Patterns (22)Eclipse (39)Files (62)General Java (69)JSPs (9)Java Basics (11)Linux (23)Logging https://blogs.oracle.com/arungupta/entry/totd_136_default_error_page (5)Maven (88)Search (12)Servlets (20)Struts (1)Text (19)Tomcat (8)Version Control (8)Windows (2)XML (1) How do I create a JSP error page to handle exceptions? Author: Deron Eriksson Description: This Java tutorial describes how to create a JSP error page to handle exceptions. Tutorial created using: Windows XP || error page JDK 1.5.0_09 || Eclipse Web Tools Platform 2.0 (Eclipse 3.3.0) || Tomcat 5.5.20 Page: 1 2> When an exception is thrown in your web application and it is not caught, you will typically see the result featuring the exception displayed in your browser window, as shown here: Rather than displaying the above default page when an exception error page configuration occurs, you can redirect the user to a custom-written error page for a particular type of exception. You can do this via the error-page element in web.xmlW, in which you can specify an exception-type and the location of the resource where a user should be sent if an error occurs. In this example, I specified the exception-type as java.lang.Throwable so that all exceptions would be sent to the error.jsp page. Error Page using Servlets 3.0 - Improved productivity using Java EE 6 By arungupta on May 17, 2010 Servlets 2.x allowed to create a mapping between an HTTP error code or an exception type to the path of a resource in the Web application. This is achieved by specifying an "error-page" element in the "web.xml". The element definition looks like: So any HTTP error code or an exception thrown within the application can be mapped to a resource bundled with the application. Here is a sample: