aspose file tools*
The moose likes Servlets and the fly likes Can I restrict number of instances to servlet? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Servlets
Bookmark "Can I restrict number of instances to servlet?" Watch "Can I restrict number of instances to servlet?" New topic
Author

Can I restrict number of instances to servlet?

Murali Mohan
Ranch Hand

Joined: Jul 07, 2003
Posts: 47
Hi,
Can I restrict the number of instances to servlet? say for example 3.
Regards,
Murali
Anonymous
Ranch Hand

Joined: Nov 22, 2008
Posts: 18944
maybe this thread helps you
click me
William Brogden
Author and all-around good cowpoke
Rancher

Joined: Mar 22, 2000
Posts: 12835
    
    5
A single container will only make one instance of a servlet. Its in the servlet API that way.
I don't know why this keeps coming up.
Bill
Afroz Ahmed
Ranch Hand

Joined: Jan 18, 2004
Posts: 64
Hello William ,

I am a servlet learner.
If single container creates one instance of a particular servlet,then what happens when the servlet is implemented SingleThread.Is single instance of servlet is enough for this situations?Pl exaplian me.
What happens when more requests are coming for the same servlet at the same time?Will that single instance is taking care of all requests?And what the <load-on-startup> tag will make us to do?

Thanks.


The value of an idea lies in the usage of it.
William Brogden
Author and all-around good cowpoke
Rancher

Joined: Mar 22, 2000
Posts: 12835
    
    5
1. SingleThreadModel interface - don't do it, not recommended, was in the original servlet API (I suspect) to help people get started but is now considered a bad idea.
2. Standard servlets - One instance handles all requests by having a separate Thread for each request. That is why we say that you must NOT use servlet instance variables for data specific to a given request. Any number of request Threads can be executing a servlet "at the same time."
Thinking about programming this way requires a major re-orientation from thinking about single-user desktop applications.
3. load-on-startup is used to request that the servlet container create an instance of a servlet when the server starts, and control the order in which servlets are created.
Bill
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Can I restrict number of instances to servlet?