Win a copy of Cross-Platform Desktop Applications: Using Node, Electron, and NW.js this week in the JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

what is use of page object?  RSS feed

 
ankur rathi
Ranch Hand
Posts: 3830
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
On page 311 on HFS&J:

pageContext getAttribute(String) is for page scope.

Then what is the use of page implicit object???

Thanks.
[ December 07, 2005: Message edited by: Bear Bibeault ]
 
Adeel Ansari
Ranch Hand
Posts: 2874
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
page is an object of type JspPage, or you can say javax.servlet.Servlet. Since Servlet is a parent of JspPage. Please refer to JSP.12.1.1 of JSP 2.0 Spec. I believe page object works like this.


Whereas, pageContext extends JspContext and is to provide useful context information. As you know it is there in JSP.12.2.2 of JSP 2.0 Spec.
 
ankur rathi
Ranch Hand
Posts: 3830
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Adeel Ansari:


Whereas, pageContext extends JspContext and is to provide useful context information. As you know it is there in JSP.12.2.2 of JSP 2.0 Spec.


I suppose, application object is for context (application) information, not the pageContext object.
 
Vishnu Prakash
Ranch Hand
Posts: 1026
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
From Spec: Page:75

About page implicit object.


page - Objects with page scope are accessible only within the page where they
are created. All references to such an object shall be released after the response is sent back to the client from the JSP page or the request is forwarded somewhere else. References to objects with page scope are stored in the pageContext object

[ December 07, 2005: Message edited by: Vishnu Prakash ]
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 66141
141
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The page implicit object (not to be confused with pageContext) is a reference to the implementation object for the JSP. Essentially it is the this reference for the JSP's implementation class.

i can think of no reason that you would need to access this object. Of course at this point, I see no reason to have scripting on the JSP pages at all, but that's deeper issue.
 
ankur rathi
Ranch Hand
Posts: 3830
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Bear Bibeault:
The page implicit object (not to be confused with pageContext) is a reference to the implementation object for the JSP. Essentially it is the this reference for the JSP's implementation class.

i can think of no reason that you would need to access this object. Of course at this point, I see no reason to have scripting on the JSP pages at all, but that's deeper issue.


Page is this then why we set page scope attribute in pageContext???

Thanks.
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 66141
141
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Because page (or this) is not a scoped context. pageContext is.
 
ankur rathi
Ranch Hand
Posts: 3830
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Bear Bibeault:
Because page (or this) is not a scoped context. pageContext is.


Sorry Bear, I didn't get this.
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 66141
141
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The object referenced by page is simply not designed to serve as a scoped context. Your question is a lot like asking why you can't use the brake pedal to steer a car. It's not what it was designed for.

If you want to store a scoped variable in page context, you store it in the pageContext object. That's pretty straight-forward and simple.
 
ankur rathi
Ranch Hand
Posts: 3830
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Bear.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!