File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Web Component Certification (SCWCD/OCPJWCD) and the fly likes Difference between Page and PageContext Implicit object Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Certification » Web Component Certification (SCWCD/OCPJWCD)
Bookmark "Difference between Page and PageContext Implicit object" Watch "Difference between Page and PageContext Implicit object" New topic

Difference between Page and PageContext Implicit object

sarang bharambe
Ranch Hand

Joined: Apr 01, 2005
Posts: 40
Hello Ranchers,

Can anyone explain the difference between Page and PageContext implicit object that are available to the JSP?

Sarang Bharambe

SCJP 1.4 (86%)<br />SCWCD 1.4 (86%)<br />----------<br />If You dont succeed at first time,call it Version 1.0 !!!
Gaurav Gambhir
Ranch Hand

Joined: Mar 04, 2006
Posts: 256
The implicit variable page is of class java.lang.Object and it refers to instance of generated servlet. It is declared as
Object page=this
<%= page.getServletInfo() %> will give Error
getServletInfo() is not a method of java.lang.Object
<%= ((Servlet)page).getServletInfo() %> is valid

pageContext variable is of type javax.servlet.jsp.PageContext. The PageContext class is the abstract class and JSP engine vendor provides its concrete subclass.
�Store reference to implicit objects,
�Provide method to get and set attributes in different scopes.
�Provide convenience methods for transferring request to other resources in web application.
Nidhi Garg

Joined: Jun 19, 2009
Posts: 21
pageContext has some usefu page attributes , access to request , response, session as well as JspWriter (referenced by out). It can be used for including another URLs content or for forwarding like: pageContext.forward("other.jsp");
I agree. Here's the link:
subject: Difference between Page and PageContext Implicit object
jQuery in Action, 3rd edition