• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Can I restrict number of instances to servlet?

 
Murali Mohan
Ranch Hand
Posts: 47
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
Can I restrict the number of instances to servlet? say for example 3.
Regards,
Murali
 
Anonymous
Ranch Hand
Posts: 18944
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
maybe this thread helps you
click me
 
William Brogden
Author and all-around good cowpoke
Rancher
Posts: 13058
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 64
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
William Brogden
Author and all-around good cowpoke
Rancher
Posts: 13058
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic