JSP implicit object "page"

The page object is an instance of a java.lang.Object class. It represents the current JSP page. That is, it serves as a reference to the java servlet object that implements the JSP page on which it is accessed. It is not advisable to use this page implict object often as it consumes large memory.
Example of implict object "page" :
index.html
<html> <head> <title>implict object exception example </title> </head> <body> <form action="devide.jsp" method="post"> <fieldset> <legend> <font face="Courier New" size="+1" color="red"> Enter Number </font> </legend> <table> <tr> <td>First Number </td> <td> <input type="text" name="first"> </td> </tr> <tr> <td>Second Number </td> <td> <input type="text" name="second"> </td> </tr> <tr> <td colspan=2> <input type="submit" value="Devide"> </td> </tr> </table> </fieldset> </form> </body> </html>
devide.jsp
<%@ page language="java" errorPage="errorPage.jsp"%> <html> <head> <title>Devide number jsp page </title> </head> <body> <% int a=Integer.parseInt(request.getParameter("first")); int b=Integer.parseInt(request.getParameter("second")); int c=a/b; out.println("Result : "+ c); %> </body> </html>
errorPage.jsp
<%@ page language="java" isErrorPage="true"%> <html> <head> <title>display error page </title> </head> <body> <%=exception %> </body> </html>
Output
page
page
page
page
Download this example
 



 

Latest Tutorial


Most Visited Tutorial