tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Kitching Simon <Simon.Kitch...@orange.ch>
Subject RE: Servlet Variables
Date Mon, 23 Oct 2000 13:14:33 GMT
Hi Wes,

First of all, it helps if you state the version of tomcat, and the OS.
There are now at least 3 different versions of tomcat out there,
3.1 (latest official release), 3.2 (nearly released) and 4.0 (experimental),

each with different problems.

However, I am pretty sure that they all handle threading in the same
manner; unless you do something to explicitly disable it, each request
gets its own thread but not a separate object instance. Thus, a servlet 
can have multiple threads running in it simultaneously. Each thread will, 
however, have different parameter objects (like the request object) and 
of course its own copy of local variables in the service functions. 
This is all as per the sun spec.

It just sounds to me like you are storing some variables as object
attributes of the servlet; you can't do this. Use local variables
within the service function, not instance member variables. 

Either that, or the logging function that you are calling is not
thread-safe..

Cheers,

Simon

> -----Original Message-----
> From:	Wes Settle [SMTP:WSettle@concentrex.com]
> Sent:	Monday, October 23, 2000 3:13 PM
> To:	'tomcat-user@jakarta.apache.org'
> Subject:	Servlet Variables
> 
> I hope this question is not too basic.  I am working with a Java Servlet
> in
> Jakarta Tomcat and seem to be having difficulty with the way that the
> servlet is handling multiple requests.  It appears that the servlet's
> variables are sharing values and not holding explicit values for each
> request.  For example, logging is done by the servlet per machine name
> making the request (getHostName()).  If multiple requests are made to the
> servlet, the log files are all crossed.  Is there something we are
> overlooking in getting the servlet to thread properly?  The servlet
> extends
> HttpServlet.
>  
> Thanks in advance for any help
>  
> TWS

Mime
View raw message