aspose file tools
The moose likes JSP and the fly likes Difference between Page and PageContext Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login
JavaRanch » Java Forums » Java » JSP
Reply Bookmark "Difference between Page and PageContext" Watch "Difference between Page and PageContext" New topic
Author

Difference between Page and PageContext

jose chiramal
Ranch Hand

Joined: Feb 12, 2010
Posts: 266
Can someone please clarify the difference between Page and PageContext impilcit objects in jsp ?

page : page is of class java.lang.Object,and it refers to instance of generated servlet. // what does this mean ?

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

Am not able to get the difference between these both, please assist.
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 56224
    
  13

Please be sure to ask JSP questions in the JSP forum. I have moved this post there for you.


[Smart Questions] [JSP FAQ] [Books by Bear] [Bear's FrontMan] [About Bear]
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 56224
    
  13

JSPs are implemented by generating a servlet. The page variable refers to the servlet instance.

As your JSP should not have any Java code in it, this is no longer useful.
Lalit Mehra
Ranch Hand

Joined: Jun 08, 2010
Posts: 369

it means ...

with page ... you can work with the servlet

with pageContext you can work with the jsp


http://plainoldjavaobject.blogspot.in
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 56224
    
  13

Lalit Mehra wrote:with page ... you can work with the servlet , for example setting attributes

No. That is not the way to deal with "attributes" (scoped variables).
Lalit Mehra
Ranch Hand

Joined: Jun 08, 2010
Posts: 369

Bear Bibeault wrote:
No. That is not the way to deal with "attributes" (scoped variables).


Then how do we use page in real ... ???

I mean we use it in our jsp page as <@ page ... >

what else ???
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 56224
    
  13

I've already pointed out that it is completely useless in modern JSP. In fact, it was pretty useless in ancient JSP as well. I never used it for anything.
Lalit Mehra
Ranch Hand

Joined: Jun 08, 2010
Posts: 369

thanks DEAR Mr. Bear
Nilesh Miskin
Ranch Hand

Joined: Jun 17, 2010
Posts: 44
page & pageContext both are implicit objects in a JSP.
page is of type java.lang.Object & refers to the instance of servlet generated from 'this' JSP.
pageContext is of type javax.servlet.jsp.PageContext.
It does following:
1. provides methods to get & set attributes in different scopes.
2. provides methods to include or forward the current request to other active componets in the application
3. provides a mechanism to handle errorpage exceptionn processing.
4. provides mechanism to manage session usage by the page

As Bear suggested, there are better ways to deal with attributes in different scopes.


Nilesh Miskin
 
I agree. Here's the link: http://ej-technologies/jprofiler - if it wasn't for jprofiler, we would need to run our stuff on 16 servers instead of 3.
 
subject: Difference between Page and PageContext
 
Similar Threads
difference between PageContext and Page object
doubt in implicit objects
Implicit objects in JSP
the difference...
pageContext