Implicit Objects in JSP, exception implicit object in JSP, How to redirect a JSP page to the Exception page when an exception occured


Implicit Objects in JSP, exception implicit object in JSP, How to redirect a JSP page to the Exception page when an exception occured

exception is an object of Throwable class, It is used to print the exception occurred in a JSP page. It is only use with that JSP page which is the common error page of entire JSP application. If the page is not an error page then there is no use of exception object.
When any exception is occurred in any JSP page the page automatically redirect to the error page.

Example for exception object

<%@page language="java" isErrorPage="false" errorPage="handleError.jsp"%>
<html>
<%
int x=10;
int y=x/0;
%>
</html>

handleError.jsp

<%@page language="java" isErrorPage="true" %>
<html>
<body>
<h3>following error occured<%=exception%></h3>
</body>
</html>

The entire application has the only one errorPage for handling the errors and that particular page has the isErrorPage="true" attribute in page directive.

{ 0 comments... read them below or add one }

Post a Comment