> -----Original Message-----
> From: A mailing list for discussion about Sun Microsystem's Java Servlet
> API Technology. [mailto:[EMAIL PROTECTED]]On Behalf Of Paul Szynol
> Sent: Friday, September 17, 1999 1:10 PM
> To: [EMAIL PROTECTED]
> Subject: can each session have its own, restricted and persistent
> instance of an object?
>
>
> is it possible for each session that accesses a servlet to have its own,
> restricted and persistent instance of an object or objects (e.g., an array
> or a vector, etc)?

Technically, servlets access sessions. But they can add objects to a session
(like a shopping cart).

'restricted': in the sense that the servlet API allows servlets in the same
ServletContext access.

'persistent': in the sense the data will last as long as the HttpSession object
does in the servlet engine (which for a variety of reasons could mean not too
long).

> will multithreading accomplish this?

Unless otherwise specified (thru SingleThreadModel), servlets are
multi-threaded. I believe sessions are synchronized (at least for modification).
But the data in the sessions (eg, your shopping cart) isn't. You need to make
sure the data that your servlets (eg, AddToShoppingCartServlet and
ConfirmOrderServlet) use, is coherently synchronized.

-s

___________________________________________________________________________
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