No servlet engine I know of creates two instances of a servlet the way you
describe it.  The init() method is "guaranteed" (from Servlet API) to be called
only once at start up.

You can store variables that will be common to all threads by putting them in
context. (context.setAttribute())

Check the servlet API.

dave.

Cezar Totth wrote:

> On Mon, 17 May 1999, jon * wrote:
>
> > > I would like a "SingleInstanceServlet" interface,
> > > in order to force servlet engine NOT to create multiple
> > > instances of a certain servlet.
> > >
> > > This would guarantee that all concurent requests share the same
> > > local variables.
> >
> > Why in the world would you want to take the multi-user nature of serving
> > dynamic websites and focus that into a single threaded system? What exactly
> > would you gain by doing that?
> >
> Hi, not single-threaded was what I meant.. I said single instance -
> multithreaded, of course (except for the case it implements
> SingleThreadedModel too - when it becomes single-threaded).
>
> I suppose some servlet engines create (are not restricted from creating)
> multiple instances for the same servlet, for distributed-engines
> or STM model optimisations.
>
> Sometimes I dont want that to happen, like when I want to
> keep some entity-data (global object, shared betwen all sessions)
> in local variable, and need to be sure that these variables are unique,
> not (re)created at each servlet.init() call.
>
> Cezar
>
> ___________________________________________________________________________
> To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
> of the message "signoff SERVLET-INTEREST".
>
> Archives: http://archives.java.sun.com/archives/servlet-interest.html
> Resources: http://java.sun.com/products/servlet/external-resources.html
> LISTSERV Help: http://www.lsoft.com/manuals/user/user.html

--
David Mossakowski        [EMAIL PROTECTED]
http://www.dwdog.com/styk      212.310.7275

"I don't sit idly by, I'm planning a big surprise"
F         U         G         A        Z        I

___________________________________________________________________________
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff SERVLET-INTEREST".

Archives: http://archives.java.sun.com/archives/servlet-interest.html
Resources: http://java.sun.com/products/servlet/external-resources.html
LISTSERV Help: http://www.lsoft.com/manuals/user/user.html

Reply via email to