Re: servlet instance problem

2004-11-24 Thread Ben Souther
On Wed, 2004-11-24 at 01:25, Satish Plakote wrote:
 Hi
 I am have a web application that does a lot of processing. I have a load on 
 startup servlet that will get init information for me.
 when 2 users submit the form.. i noticed that one instance of the servlet is 
 running and the other request waits for some time for
 processor and just dies off.. Servlets are suppose to be thread safe and 'n' 
 number of intances can be created . why only one
 instance running  at a given time.. My servlet is not a single instance 
 servlet and i have not placed an restrictions of that sort..
 can anyone help me with this ??

First, if you're running a Servlet 2.3 or higher version of Tomcat (4x
and up, I think) you should move your initialization code to a context
listener.

Servlets are threadsafe but your code isn't necessarily.  Are both
instances making calls to methods in another object (maybe one that
locks a file or resource while working on it).  Are you using instance
variables in your servlet?



-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



RE: servlet instance problem

2004-11-24 Thread Shapira, Yoav

Hi,

I am have a web application that does a lot of processing. I have a
load on
startup servlet that will get init information for me.
when 2 users submit the form.. i noticed that one instance of the
servlet
is running and the other request waits for some time for
processor and just dies off.. Servlets are suppose to be thread safe
and
'n' number of intances can be created . why only one
instance running  at a given time.. My servlet is not a single instance
servlet and i have not placed an restrictions of that sort..
can anyone help me with this ??

Your understanding of the how Servlet Spec dictates servlet instance
creation is incomplete.  While n instances of a servlet *may* be created
by the container, that's not required, and that's only one way to manage
things.  What Tomcat does is create one instance of each servlet for
every servlet tag in your web.xml, and then a pool of threads which
can use this servlet (aka the request processing threads).

So even though your servlet doesn't implement SingleThreadModel (I hope,
since that interface is gone, evil, and misleading), there's only one
instance of it.  And you're responsible for synchronization as needed
for your domain-level objects and business processes.

Yoav Shapira http://www.yoavshapira.com



This e-mail, including any attachments, is a confidential business 
communication, and may contain information that is confidential, proprietary 
and/or privileged.  This e-mail is intended only for the individual(s) to whom 
it is addressed, and may not be saved, copied, printed, disclosed or used by 
anyone else.  If you are not the(an) intended recipient, please immediately 
delete this e-mail from your computer system and notify the sender.  Thank you.


-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]