Tuyen Tran wrote:
> If a user has two browsers open such that both browsers have the same
> session id cookie, and then simultaneously accesses the same servlet from
> both browser, does the servlet engine serialize the requests? Does the spec
> say anything about this behavior?
>
> It seems that without serialization, the servlet developer can't assume
> exclusive access to an object pulled from HttpSession.
>
> Tuyen Tran
>
Servlet engines only serialize access to servlets that implement
SingleThreadModel. For all other cases (either instance variables within a
servlet itself, or user objects stored in an HttpSession), you are responsible
for any synchronization that is required.
Note that you don't need two windows open to trigger this kind of situation.
Imagine the following scenario:
* User clicks a link to a servlet
that does a long database query
to prepare its output.
* Servlet starts running and is
executing the query
* User gets impatient and clicks
the STOP button
* Servlet is oblivious to this, and
keeps on running
* User clicks a link to either the
same servlet or a different servlet
that is accessed in the same session
* Second servlet begins executing
--> Race condition on session variables unless you have taken proper care to
synchronize things.
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