> To sum up, the questions were:
>  Do multiple threads travel through the servlet?
Yes they can. Simultaneous access of a servlet by one or more clients can
result in multiple threads invoking methods on the servlet instance. This
corresponds
to multiple independent sessions, not multiple requests in one session. You
see
people speak of using HttpSessions to store information when they are
describing
a servlet that manages stateful sessions. A session is a multi-request
interaction
between a client and the servlet. A stateful session is multi-request
interaction between
a client and the servlet where the servlet is mainting state/data about the
client.
A shopping cart is a prototypical example of such a stateful session.

>  Do you think the phrase "don't use Object instance variables to save
state
> information" is implied or am I overly concerned here?  (Can a person
safely
> use Object Instance variables in Servlets just like typical standard Java
> objects?)
>
You can't use instance variables to save state in a servlet because one
servlet instance
serves multiple clients. Serving multiple clients does not require a
multi-threaded
servlet. Even if you had your servlet implement the
javax.servlet.SingleThreadModel
interface to ensure that only one request was active in the servlet at any
given time,
instances variables do not provide the correct state storage. You are
interested in saving
state about the client interacting with the servlet. You need a session id
or cookie identifying
the client to do this. The HttpSession mechanism makes this simple to do.




***********************************************************************
Bear Stearns is not responsible for any recommendation, solicitation,
offer or agreement or any information about any transaction, customer
account or account activity contained in this communication.
***********************************************************************

___________________________________________________________________________
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