struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Mark Woon <morph...@SMI.Stanford.EDU>
Subject Re: Quick question about iterators & beans on a page
Date Sat, 16 Feb 2002 18:50:51 GMT
Adam Hardy wrote:

> On Sat, 16 February 2002, Mark Woon wrote:
> > > (2) is it thread-safe? Guess it must be, but why? Does it all stay in one thread
of the main struts controller servlet, and out of reach of any other threads?
> >
> > Depends on what you mean.  If it's a read-only collection, then sure, it's "thread
safe".  But if you expect that list to change, then no, it's not thread-safe, because multiple
> > requests from the same user would be able to access the collection.
> >
> > -Mark
> Argh! The list is user dependent - it's got to be thread-safe.
> So if the Action puts the array for the iterator in the request, how can I make sure
that no other user gets it?
> I know what you're going to say - put it in the session, right? But then at the end of
the day a user who uses the site intensively all day might end up with a rowset or even two
in their session for every page in the site.

No, it's safe in the request.  Question #1 referred to putting things in the session.  I assumed
that Question #2 referred to putting things in the session to.  Things in the request are
thread safe, as Ted mentioned.  Things
in the session aren't.

Also, if you're sticking things in the session, you can remove them yourself once you know
you're done with them rather than wait for their session to timeout.


To unsubscribe, e-mail:   <>
For additional commands, e-mail: <>

View raw message