• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Difference between Page and PageContext Implicit object

 
sarang bharambe
Ranch Hand
Posts: 40
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello Ranchers,

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

Regards,
Sarang Bharambe
 
Gaurav Gambhir
Ranch Hand
Posts: 256
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
page
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
Consider
<%= page.getServletInfo() %> will give Error
getServletInfo() is not a method of java.lang.Object
<%= ((Servlet)page).getServletInfo() %> is valid

pageContext
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.
PageContext.forward(�other.jsp�);
 
Nidhi Garg
Greenhorn
Posts: 21
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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");
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic