Hi

Michael Weissenbacher wrote:

> that is a simple problem of understanding: there is only one servlet object
> that is used by multiple threads. by having this in mind, your object
> variables are also shared, as would be static variables...

Francis Pallini wrote:

> Application-wide data (within a container in the case of balanced servers)
> can be put in instance variables, but access must then be synchronized.
> User-related data must be put in the session object...

Thanks for the help here.  Gods, I've been writing various servlet applications
for over a year and it seems I've been working with a fundamental
misconception.

This is what comes from spending too much time by yourself, and more
importantly assuming that single user test results extend to multiple users

I guess I have two options, either make the servlet implement the
SingleThreadModel interface, or create some new classes to encapsulate the
appropriate data, and either store that in the session or in some instance
variable like a hashtable ...

Thanks again.

CHEERS> SAM





>
> -----Original Message-----
> From: Sam Joseph [mailto:[EMAIL PROTECTED]]
> Sent: Thursday, July 26, 2001 11:18 AM
> To: [EMAIL PROTECTED]
> Subject: Weird thread/security problem
>
> Hi,
>
> So I think this is a thread/security issue, but I am not sure.  However
> it is definitely weird.
>
> I have been conducting some tests with multiple users.  Various servlets
> are contacted that supply pages to each user, that include information
> such as user name etc.  The version of tomcat in use is 3.2.1, and
> clearly I should upgrade to 3.2.3, but the tomcat is provided by my
> service provider so that might take some time.
>
> Anyway, the problem is that sometimes when two users are accessing the
> system simulatenously the information for one user will be displayed,
> briefly, to the other user.  The system I have developed is quite
> complicated so I can't rule out that this is a problem with the code,
> but I'm not using static variables or anything that would allow this
> swap over.  I mean each user has an object associated with them that
> contains their user name, but these are local variables to the servlet.
>
> Are there or have there been problems with tomcat that would explain
> this problem?  I mean tomcat creates a separate thread for each servlet
> right? Different user, different thread, so their data shouldn't be
> available to each other.
>
> Am I overlooking something here?  Should I be mailing to the developer's
> list?
>
> And on the same topic, does anyone know of any software that will
> simulate multiple users, without me having all my friends test the
> system.  I mean some software (ideally free or shareware) that would
> simulate the stream of http requests, I guess I could hack something
> together myself, but if there's something already out there that would
> be great.
>
> Thanks in advance.
>
> CHEERS> SAM

Reply via email to