Hello Devs,


In this tutorial, we are going to learn about JSP Exception Implicit Object. In JSP, exception is a instance of java language.

This object is only available for error pages and used for print Exception.



index.html

<html>
<head>
<title>Exception Implicit Object</title>
</head>
<body>
<form action="action.jsp">
First Number:<input type="text" name="fno" />
Second Number:<input type="text" name="sno" />
<input type="submit" value="submit"/>
</form>
</body>
</html>

<%@ page errorPage="exception.jsp" %>
<%
String num1=request.getParameter("fno");
String num2=request.getParameter("sno");
int s1= Integer.parseInt(num1);
int s2= Integer.parseInt(num2);
int exp= s1/s2;
out.print("Output is: "+ exp);
%>

<%@ page isErrorPage="true" %>
Got this Exception: <%= exception %>


I hope this example helps you.