Create Error Page In Jsp
Contents |
handle particular error codes? Tutorial Categories: Ajax (1)Ant (16)Apache Web Server (8)Bioinformatics (10)Cascading Style Sheets (47)Classes and
Custom Error Page Jsp
Objects (14)Database (13)Design Patterns (22)Eclipse (39)Files (62)General Java (69)JSPs (9)Java Basics error page in jsp example (11)Linux (23)Logging (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
How To Use Error Page In Jsp
JSP error page to handle particular error codes? Author: Deron Eriksson Description: This Java tutorial describes how to create a JSP to handle particular error codes. Tutorial created using: Windows iserrorpage and error page in jsp XP || JDK 1.5.0_09 || Eclipse Web Tools Platform 2.0 (Eclipse 3.3.0) || Tomcat 5.5.20 Page: 1 2> When a particular error code occurs in the context of your JavaSW web application, such as a 404 (Not Found) or 500 (Internal Server Error), it is possible to send the user to an error page. The error code and the jsp error page template page location where the user should be sent in the event of that error can be specified in an error-page section in web.xmlW. Below, we see that when a 404 error occurs, the user is to be redirected to the error-404.jsp. Section of web.xml
ContentHandling JSP Page Errors Any number of exceptions
Jsp Error Page Print Stack Trace
can arise when a JSP page is executed. To specify error page jsf that the web container should forward control to an error page if an exception
Error Page Servlet
occurs, include the following page directive at the beginning of your JSP page: <%@ page errorPage="file-name" %> The Duke’s Bookstore application page tut-install/javaeetutorial5/examples/web/bookstore2/web/template/preludeErrorPage.jspf contains http://www.avajava.com/tutorials/lessons/how-do-i-create-a-jsp-error-page-to-handle-particular-error-codes.html the directive: <%@ page errorPage="errorpage.jsp"%> The following page directive at the beginning of tut-install/javaeetutorial5/examples/web/bookstore2/web/error/errorpage.jsp indicates that it is serving as an error page: <%@ page isErrorPage="true" %> This directive makes an object of type javax.servlet.jsp.ErrorData available to the error page so that you can retrieve, interpret, and possibly display https://docs.oracle.com/cd/E19316-01/819-3669/bnahi/index.html information about the cause of the exception in the error page. You access the error data object in an EL (see Unified Expression Language) expression by way of the page context. Thus, ${pageContext.errorData.statusCode} retrieves the status code, and ${pageContext.errorData.throwable} retrieves the exception. You can retrieve the cause of the exception using this expression: ${pageContext.errorData.throwable.cause} For example, the error page for Duke’s Bookstore is as follows: <%@ page isErrorPage="true" %> <%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %> <%@ taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt" %>
: ${pageContext.errorData.throwable.cause} Note – You can also define error pages for the WAR that contains a JSP page. If error pages are defined for both the WAR and a JSP page, the JSP page’s error page takes precedence. Previous: BufferingNext: Creating Static Content © 2010, Oracle Corporation and/or its affiliates
▼ JSP Tutorial JSP Introduction Life cycle of JSP JSP API JSP in Eclipse JSP scripting elements JSP scriptlet tag JSP expression tag JSP declaration http://www.javatpoint.com/exception-handling-in-jsp 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 error page 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>> <