Nic Ferrier wrote:

>
> >In the case of context, it's okay. But I don't think this is true
> with
> >sessions in a distributable setup!
>
> Why not? The distributed part of the implementation should be able to
> handle that.
>

Consider a user session that has a bunch of beans in it.  Consider that some
code calls a "set" method on one of those beans that changes the bean's
internal state.  How does the server know that this bean has been changed?  All
you can detect at the servlet container level is when attributes are added,
changed, and replaced.

This is one of the reasons for the spec restriction that all requests for a
particular session (at a given point in time) must be served in the same JVM.

>
> I imagine that most distribution implementations deal with sessions
> in much the same way... ie: by having the session itself communicate
> changes on it to other servers or have the session notify the session
> manager to do it.
>
> Either way there isn't a problem with handing sessions to
> sub-threads.
>

How does the session know that it has been changed (see the above scenario)?
The only thing it can detect are adding, removing, and replacing attributes --
not internal state changes on those attributes themselves.

In a distributable setup, the servlet container has the right to migrate your
session information to a different JVM and start serving requests (for this
session) there instead.  If you have started threads that are accessing this
session, there is no API for the container to tell your threads that the
instance of the session they are talking to is no longer the "current" one.

>
> Sessions are implicitly thread-safe because they are open to use by
> multiple request/response threads.
>
> >There are implications that one should be aware of. That's what I
> was
> >trying to communicate.
>

That's certainly true here, as well as in every other programming environment
:-).

Craig McClanahan

___________________________________________________________________________
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff SERVLET-INTEREST".

Archives: http://archives.java.sun.com/archives/servlet-interest.html
Resources: http://java.sun.com/products/servlet/external-resources.html
LISTSERV Help: http://www.lsoft.com/manuals/user/user.html

Reply via email to