• 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
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

About pageContext.SESSION_CONTEXTand page scope

 
Bartender
Posts: 2418
13
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
From the example here:
http://beginnersbook.com/2013/11/jsp-implicit-object-pagecontext-with-examples/


From this example:


The attributes UName is set as page scope.


It is an instance of javax.servlet.jsp.PageContext. Using this object you can find attribute, get attribute, set attribute and remove attribute at any of the below levels –

JSP Page – Scope: PAGE_CONTEXT
HTTP Request – Scope: REQUEST_CONTEXT
HTTP Session – Scope: SESSION_CONTEXT
Application Level – Scope: APPLICATION_CONTEXT


As this quote says, an attribute has 4 different levels of scopes.
The attribute UName's scope is page scope which is only limited to the current JSP.

But why UName is also associated with session scope?
 
Sheriff
Posts: 9707
43
Android Google Web Toolkit Hibernate IntelliJ IDE Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Himai,


UName is session scope. You are confusing pageContext and PAGE_CONTEXT. If I do this:


This means your attribute will be available in page scope. But if you do this:


Now you are setting the attribute in session scope i.e. it's the same as doing this:

The pageContext is an object of type PageContext and you can check the documentation of setAttribute method...
 
reply
    Bookmark Topic Watch Topic
  • New Topic