• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Can I restrict number of instances to servlet?

 
Ranch Hand
Posts: 47
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,
Can I restrict the number of instances to servlet? say for example 3.
Regards,
Murali
 
Ranch Hand
Posts: 18944
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
maybe this thread helps you
click me
 
Author and all-around good cowpoke
Posts: 13078
6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Ranch Hand
Posts: 64
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
Posts: 13078
6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Willie Smits can speak 40 languages. This tiny ad can speak only one:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic