You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by Byrom Robert-LRB005 <Ro...@invisix.com> on 2001/03/06 14:05:06 UTC

threading issues with tomcat

hello all

Im hoping someone can help, 

can someone please explain how the threading works when a new servlet is initialised within the tomcat container? If multiple requests are recieved for a servlet, is the same servlet data area shared amongst each thread that invokes the servlet? and if many requests are made for the same servet, how does tomcat deal with the demand? 

I need to know the stress that tomcat can handle.

if anyone can help this would be appreciated, 
thanks in advance.

rob


Re: threading issues with tomcat

Posted by William Brogden <wb...@bga.com>.

Byrom Robert-LRB005 wrote:
> 
> hello all
> 
> Im hoping someone can help,
> 
> can someone please explain how the threading works when a new servlet is initialised within the tomcat container? If multiple requests are recieved for a servlet, is the same servlet data area shared amongst each thread that invokes the servlet? and if many requests are made for the same servet, how does tomcat deal with the demand?

 Only a single servlet object exists in the container but there
can be many Threads executing in the code. Each Thread has
a request object and response object (and possibly a session
object) belonging to a particular request. Each Thread shares
the instance variables of the servlet but local variables in
servlet methods are unique to the Thread.

 Thats why you should not use servlet instance variables for
anything unique to a particular request. Data that has to be
associated with a particular user between requests should be
stored in the session. 

-- 
WBB - wbrogden@lanw.com
Java Cert mock exams http://www.lanw.com/java/javacert/
Author of Java Developer's Guide to Servlets and JSP 
ISBN 0-7821-2809-2