• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Head First Question

 
Mike Terry
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Folks,
i was solving the problems of Head First chapter 6 questions, but one of the options does not seem to be right for me.

Head First is saying:

"Attributes bound into a session are available to any other servlet that belongs to the same ServletContext"

Well this seems to be as wrong statement, but may be I am missing something.
Please help me understand why this statement is right? According to me ServletContext's are not specific to session, and it should not be possible for a session
to reach to another session's attributes.

Thanks in advance.
 
Ankit Garg
Sheriff
Posts: 9577
33
Android Google Web Toolkit Hibernate IntelliJ IDE Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Mike, welcome to javaranch.

The statement means that attributes in a session are not available to any servlet outside the ServletContext. You are right that session attributes can't be inter-referenced between sessions. But the point is, if I set a session attribute in servlet1, then any other servlet (lets say servlet2) which gets called on the same session can access that attribute only if servlet1 and servlet2 are in same servlet context...
 
Mike Terry
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Ankit,
It makes sense with your explanation.
Thanks alot.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic