• 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

servlet pool

 
Ranch Hand
Posts: 52
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hi friends,
it seems confusing that there's a servlet pool in the single-thread model. if we implement a servlet SingleThreadModel, no two threads will execute concurrently in the servlet's service method. in this situation, what's the use of a pool of servlet instances? i think one instance is okay, right?
tony
 
Ranch Hand
Posts: 2166
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Tony,
SingleThreadModel results in ThreadSave member variables of the servlet. If u have > 1 servlets (servlet-pool) the member variables per instance are still thread-safe.
A Servlet pool leads to faster response time. That makes sense to me, because SingleThreadModel slows down the response time.
 
tony lee
Ranch Hand
Posts: 52
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hi axel,
do you know what's a servlet pool?
it's a number of servlet objects (instances) associated with the same servlet name. each of the instances is ready (initialized) to be dispatched to a request thread by the container. i'm not sure the defination i gave is right
any ideas on it, friends?
tony
 
Ranch Hand
Posts: 1055
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Maybe this will help...

3.2 Number of Instances
By default, there must be only one instance of a servlet class per servlet definition in a container.
In the case of a servlet that implements the SingleThreadModel interface, the servlet container
may instantiate multiple instances of that servlet so that it can handle a heavy request load while
still serializing requests to a single instance.
In the case where a servlet was deployed as part of an application that is marked in the deployment
descriptor as distributable, there is one instance of a servlet class per servlet definition per VM in a
container. If the servlet implements the SingleThreadModel interface as well as is part of a
distributable web application, the container may instantiate multiple instances of that servlet in
each VM of the container.
3.2.1 Note about SingleThreadModel
The use of the SingleThreadModel interface guarantees that one thread at a time will execute
through a given servlet instance’s service method. It is important to note that this guarantee only
applies to servlet instance. Objects that can be accessible to more than one servlet instance at a
time, such as instances of HttpSession, may be available to multiple servlets, including those
that implement SingleThreadModel, at any particular time.


(Servlet 2.2 specs on servlet instances)
-anthony
 
See ya later boys, I think I'm in love. Oh wait, she's just a tiny ad:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic