What is the differnce between page and pagecontext?

Showing Answers 1 - 9 of 9 Answers

ramana

  • Aug 30th, 2006
 

diff between page and page context:

page and pagecontext are implicit objects in jsp.These are created at JSP translated time.page is used as a scope with in one jsp.pagecontext is used to initilize all implicit objects.(for example pagecontext.getServletConfig() etc)

  Was this answer useful?  Yes

kishor raja kumar

  • Sep 18th, 2006
 

  Hi All,

    What Mr.Raamana said is right,But i want to give some detailed explination on page context.

   We can say,pagecontext is a wrapper class.Which is used to wrape the implicet objects and scope variables.Succpose u want to call a web component from a non web application,we have to import  pagecontext.

what we r doing in customtags.

If i am wrong plz let me know.

Bye

kishor

  Was this answer useful?  Yes

suman

  • Sep 27th, 2006
 

Hi Friends,

   This is suman

        page and pageContext are implicit variables.

   page :   page is of class java.lang.Object,and it refers to instance of generated servlet.It is declared as

          Object page=this;

                          // this refers to the instance of this servlet

     page cannot be used to directly call the servlet methods.

1) <%=page.getServletInfo()%>

  Error bcoz page is  java.lang.Object type

 2)          <%=((servlet)page).getServletInfo()%>  <----OK:typecast

    3)       <%=this.getServletInfo()%> <-------OK

pageContext :

           pageContext is of type javax.servlet.jsp.PageContext.

          pageContext class is an abstract class.

it do following things;

 1.provide convenience methods to get and set attributes in diff scopes.

 2.provide convenience methods for transfering requests to other resources in the web application

      void include(String relativeURL)  & void forward(String relativeURL)

  Ex; pageContext.forward("suman.jsp");

3.store the references to implicit objects

  

    

Shekar B

  • Nov 18th, 2008
 

Page: The object is the Instance of page implementation servlet class that
are processing the current request.
PageContext: The PageContext specifies the single entry point to many of the
page attributes and is the convenient place to put shared data.
Provides certain convenience methods and stores references to the implicit
objects.


Methods
findAttribute,
getAttribute,
getAttributesScope,
getAttributeNamesInScope,
setAttribute.

  Was this answer useful?  Yes

Amit

  • Mar 13th, 2016
 

Page and Pagecontext are implicit objects in jsp. These are created at JSP translated time. The page object represents the generated servlet instance itself and is used as a scope with in one jsp. Pagecontext is used to initilize all implicit objects for example :- page attributes, access to the request, response and session objects, as well as the JspWriter referenced by out.

  Was this answer useful?  Yes

Give your answer:

If you think the above answer is not correct, Please select a reason and add your answer below.

 

Related Answered Questions

 

Related Open Questions