Joe,

Isn't the default behavior for servlets determined by the webserver you are
using?  Some servers do have a single servlet instance per all users, but I
know the previous version of JRUN server (3.01) instantiated a new copy of
the servlet for every new/unique session id.  I don't know about the new
version of JRUN server (3.1). I did look at the Sun page you reference
below, but it did not reference the page where the Sun standard for servlet
behavior is spelled out.

Celete

-----Original Message-----
From: Joe Cheng [mailto:[EMAIL PROTECTED]]
Sent: Tuesday, January 15, 2002 3:39 PM
To: [EMAIL PROTECTED]
Subject: Re: Downloading files with jsp/servlets...


Zvika,

The default behavior for servlets is to have a *single* servlet instance
serve all incoming requests for that servlet, simultaneously.  In other
words, it's not that each incoming request instantiates your servlet; on the
contrary, the servlet only gets instantiated once in the lifetime of your
webserver (well, more or less).

That's why it's a bad idea to declare member data fields for servlets; you
may as well be declaring static fields, because that's effectively what
you're doing.  Same thing with declaring variables in <%! %> blocks in JSP.

The exception is if you implement SingleThreadModel, which guarantees that a
single instance of a servlet will not be serving two requests
simultaneously; the spec doesn't make it clear whether that happens via
synchronization, or whether multiple instance get created.

http://java.sun.com/docs/books/tutorial/servlets/client-interaction/threads.
html

Hope that helps clear it up a little.

-jmc

===========================================================================
To unsubscribe: mailto [EMAIL PROTECTED] with body: "signoff
JSP-INTEREST".
For digest: mailto [EMAIL PROTECTED] with body: "set JSP-INTEREST
DIGEST".
Some relevant FAQs on JSP/Servlets can be found at:

 http://archives.java.sun.com/jsp-interest.html
 http://java.sun.com/products/jsp/faq.html
 http://www.esperanto.org.nz/jsp/jspfaq.jsp
 http://www.jguru.com/faq/index.jsp
 http://www.jspinsider.com

===========================================================================
To unsubscribe: mailto [EMAIL PROTECTED] with body: "signoff JSP-INTEREST".
For digest: mailto [EMAIL PROTECTED] with body: "set JSP-INTEREST DIGEST".
Some relevant FAQs on JSP/Servlets can be found at:

 http://archives.java.sun.com/jsp-interest.html
 http://java.sun.com/products/jsp/faq.html
 http://www.esperanto.org.nz/jsp/jspfaq.jsp
 http://www.jguru.com/faq/index.jsp
 http://www.jspinsider.com

Reply via email to