On Monday Aug 23, 1999, Imam, Asim, CFCTR wrote:

> I just need to confirm something for
> jsp/servlets...Everytime a client invokes a servlet, a new
> instance of that servlet is created . Is that true??  I
> mean if ten clients hitting the same servlet, is it the
> same servlet instance doing all the work or does it spawn
> ?? How does that work??

You (and the servlet engine) have a choice.  You can affect
the behavior by having the servlet implement
javax.servlet.SingleThreadModel or not.  To quote its
documentation:

  Ensures that servlets handle only one request at a
  time. This interface has no methods.

  If a servlet implements this interface, you are guaranteed
  that no two threads will execute concurrently in the
  servlet's service method. The servlet container can make
  this guarantee by synchronizing access to a single instance
  of the servlet, or by maintaining a pool of servlet
  instances and dispatching each new request to a free
  servlet.

  If a servlet implements this interface, the servlet will be
  thread safe. However, this interface does not prevent
  synchronization problems that result from servlets accessing
  shared resources such as static class variables or classes
  outside the scope of the servlet.

The specification does not demand pooling or any other
behavior reguarding this aside from what's written above.
In other words, check with the servlet engine you are using.

Howard

===========================================================================
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff JSP-INTEREST".  For general help, send email to
[EMAIL PROTECTED] and include in the body of the message "help".
For JSP FAQ, http://www.esperanto.org.nz/jsp/jspfaq.html

Reply via email to