• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • paul wheaton
  • Jeanne Boyarsky
  • Ron McLeod
Sheriffs:
  • Paul Clapham
  • Liutauras Vilda
  • Devaka Cooray
Saloon Keepers:
  • Tim Holloway
  • Roland Mueller
Bartenders:

Difference between Page and PageContext

 
Ranch Hand
Posts: 266
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Sheriff
Posts: 67753
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Please be sure to ask JSP questions in the JSP forum. I have moved this post there for you.
 
Bear Bibeault
Sheriff
Posts: 67753
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Ranch Hand
Posts: 384
Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
it means ...

with page ... you can work with the servlet

with pageContext you can work with the jsp
 
Bear Bibeault
Sheriff
Posts: 67753
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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
Posts: 384
Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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
Sheriff
Posts: 67753
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 384
Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
thanks DEAR Mr. Bear
 
Ranch Hand
Posts: 44
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
You don't know me, but I've been looking all over the world for. Thanks to the help from this tiny ad:
Smokeless wood heat with a rocket mass heater
https://woodheat.net
reply
    Bookmark Topic Watch Topic
  • New Topic