JSP exception object
JSP exception implicit object is instance of java.lang.Throwable
class .
It is used for exception handling in JSP. But it can only be used in error pages, which means a JSP page should have isErrorPage to true in order to use exception implicit object.
Example of exception implicit object:
index.html
<html> <body> <form action="first.jsp"> Enter First No:<input type="text" name="firstnum" /> Enter Second No:<input type="text" name="secondnum" /> <input type="submit" value="Get Results"/> </form> </body> </html>
first.jsp
<%@ page errorPage="error.jsp" %> <% String n1=request.getParameter("firstnum"); String n2=request.getParameter("secondnum"); int n1= Integer.parseInt(n1); int n2= Integer.parseInt(n2); int r= v1/v2; out.print("Output is: "+ r); %>
error.jsp
<%@ page isErrorPage="true" %> <%= exception %>
[…] exception Object […]
LikeLike