CodesJava

Easy learning with example program codes

JSP exception implicit object


JSP exception object is an instance of javax.servlet.jsp.JspException. This object is used in exception handling to print the error message. But is only be used on that jsp page on which isErrorPage attribute is true.

Example:

welcome.jsp

<html>
	<head>
		<title>Exception handling example</title>
	</head>
	<body> 
		<%	
			out.print(10/0); 
		%>
	</body>
</html>

errorPage.jsp

<%@ page isErrorPage="true" %>
 
<html>
	<head>
		<title>error page</title>
	</head>
	<body> 
		Occurred exception is: <%= exception %>		
	</body>
</html>

web.xml

<web-app>
 
  <error-page>  
  	<exception-type>java.lang.Exception</exception-type>  
  	<location>/error.jsp</location>  
  </error-page> 
 
  <welcome-file-list>
    <welcome-file>welcome.jsp</welcome-file>
  </welcome-file-list>
</web-app>

Output:

jsp example 26
 
Download this example.
 
Next Topic: JSP action tags with example.
Previous Topic: JSP page implicit object with example.

Related Topics:

JSP implicit objects with example.
JSP out implicit object with example.
JSP request implicit Object with example.
JSP response implicit object with example.
JSP config implicit object with example.
JSP application implicit object with example.
JSP session implicit object with example.
JSP pageContext implicit object with example.
JSP page implicit object with example.
JSP exception implicit object with example.

 

Sign Up/ Sign In
Ask a Question


Industrial Training

We offers Placement Oriented Training on Java, Spring, JSF, Hibernate, PHP, AngularJS, Angular 4, PLSQL, Oracle BI Publisher etc. We also provides Online training, please mail us at hr@codesjava.com.

Development

We also provides the Development services for Website Development , Java Development, PHP Development, Android App Development etc. You can contact us on hr@codesjava.com.

Copyright © 2018 CodesJava DMCA.com Protection Status SiteMap Reference: Java Wiki