• 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

HFSJ question on session attribute

 
Ranch Hand
Posts: 54
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
This question comes from the end of chapters 6 session management of head first servlet and jsp:

Which statements about session attributes are true?

One of the correct answer is: "Attributes bound into a session are available to any other servlet that belongs to the same ServletContext".

I am not quite sure why this answer is correct. My understanding is that a session attribute is only available to a servlet if the session is passed into the servlet in the request parameter. That is, a servlet can not just grab a attribute from any session it wants to. Can someone clarify?
 
Ranch Hand
Posts: 431
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
No. Attributes of a session will not be available to any app in the same ServletContext unless that servlet also uses the same Session. You tell the complete questions and answers. One more thing, an attribute with Session scope wont be available to all other apps which are sharing same Request object. For that you need to explicitly put the attribute in the Request attribute or those apps also have to use the same session. Got it?
 
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Kelly,

This is a printing mistake in HFSJ.
The link below answers ur question
http://www.oreilly.com/catalog/headservletsjsp/errata/headservletsjsp.confirmed

Jyothi

----------------------------

SCJP 1.4
 
Ranch Hand
Posts: 79
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
A request belongs to a Session. If that request is forwarded to another application then even then the session attributes will not be available to it. Is my understanding right?

Session does not migrate from one app to another.
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic