FAQ


Advertisement



What is the page implicit object?

The page implicit object is of type Object and it is assigned a reference to the servlet that executing the _jspService() method. Page is the instance of the JSP page's servlet processing the current request. Not typically used by JSP page authors. Thus in the Servlet generated by tomcat the page object is created as

Object page = this;

Since page is a variable of type Object, it cannot be used to directly call the servlet methods. To access any of the methods of the servlet through page it must be first cast to type Servlet.

<%= this.getServletInfo(); %>
<%= ((Servlet)page).getServletInfo(); %>

But the following code will generate error, because can not use page directly without casting:

<%= page.getServletInfo(); %>

Note that page is not the same as the pageContext object (What is difference between page and pageContext in JSP pages?).


Printer-friendly version Printer-friendly version | Send this 
article to a friend Mail this to a friend

Previous Next vertical dots separating previous/next from contents/index/pdf Contents

  |   |