File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Web Component Certification (SCWCD/OCPJWCD) and the fly likes confused about session scope.... Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Certification » Web Component Certification (SCWCD/OCPJWCD)
Bookmark "confused about session scope...." Watch "confused about session scope...." New topic
Author

confused about session scope....

Neil Mc
Ranch Hand

Joined: Oct 20, 2003
Posts: 32
Hi,

In the 'coffee cram' for chapter 6 in the HFS book, question 7 (c) is listed as a correct answer...

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


Is this correct ? I would have thought that they would only have been available to a servlet with access to that particular session NOT the servlet context !

Maybe I'm missing something here, but if this is correct, then does that not defeat the purpose of having a session scope ?

Any help, much appreciated.
Bahadar Khan
Ranch Hand

Joined: Jun 19, 2003
Posts: 81
There is one ServletContext for an entire web application. This implies all the sevlets in that application has same one ServletContext. But here Session has nothing to do with ServletContext. What that statement means is " All the servlet that belongs to that ServletContext, would be able to access that session object, if any of those servlets are used for servicing that particular client whom that session belongs".

Hope it might help!
Kathy Sierra
Cowgirl and Author
Ranch Hand

Joined: Oct 10, 2002
Posts: 1572
Bahadar is absolutely right -- that sentence is ambiguous, and we should have added the rest of it to make it absolutely clear.

So, the assumption is that anything within the same context can have access to the session, but that's assuming the web resource is involved in the session!

You can give yourself credit for that question regardless of whether you check that answer as right or wrong, since it depends on how you interpret it.

Cheers,
Kathy
Roger Yates
Ranch Hand

Joined: Aug 31, 2004
Posts: 118
Neil - thanks for raising this one. I had the same query when reading the answer and thinking "but hang on - only if they are involved in the same session..." but didn't get round to posting anything here.

Thanks Kathy - I'll give myself a point for that question now - that brings me to 10/15 and some more reading to do!

Cheers,
Roger


Cheers,<br />Roger<br />SCJP 1.2, 1.4, SCBCD 1.3, SCWCD 1.4
 
Don't get me started about those stupid light bulbs.
 
subject: confused about session scope....