• 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
  • Paul Clapham
  • Ron McLeod
  • Jeanne Boyarsky
  • Tim Cooke
Sheriffs:
  • Liutauras Vilda
  • paul wheaton
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Frits Walraven
Bartenders:
  • Piet Souris
  • Himai Minh

Servlet Instance?

 
Greenhorn
Posts: 25
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi all,
Can you tell me how many servlet instances will be created if there are 20 requests to that servlet?
Thanks for your help.
Rock.
[ July 14, 2006: Message edited by: Bear Bibeault ]
 
Sheriff
Posts: 14691
16
Eclipse IDE VI Editor Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Only one (in a non-distributable environment)
 
Ranch Hand
Posts: 35
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Try this link
http://forum.java.sun.com/thread.jspa?threadID=619289&messageID=3475708
 
Ranch Hand
Posts: 131
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Amit,

thanks for the link but it still doesn't clear up the question
they talk about implementing SingleThreadModel but then someone says it's depricated
but it also sounds like there is probably only one instance and in any event you should treat things like there's only one instance
give that, how does the single instance handle multiple requests?
does it que em up and handle em one at a time or does it internally spawn a seperated thread to handle each?
inquiring minds want to know

Dave
 
Sheriff
Posts: 13411
Firefox Browser VI Editor Redhat
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Dave Robbins:
Amit,

thanks for the link but it still doesn't clear up the question
they talk about implementing SingleThreadModel but then someone says it's depricated
but it also sounds like there is probably only one instance and in any event you should treat things like there's only one instance
give that, how does the single instance handle multiple requests?
does it que em up and handle em one at a time or does it internally spawn a seperated thread to handle each?
inquiring minds want to know
Dave



In both cases, a new thread is spawned for each request.

With (the deprecated) SingleThreadModel a new instance of the servlet is instanciated for each request. Many servlet containers will pool the instances to improve efficiency.

For servlets not implementing SingleThreadModel, all requests are passed to the same instance of the servlet (all threads call the same instance of the servlet).
[ July 14, 2006: Message edited by: Ben Souther ]
 
permaculture is a more symbiotic relationship with nature so I can be even lazier. Read tiny ad:
Free, earth friendly heat - from the CodeRanch trailboss
https://www.kickstarter.com/projects/paulwheaton/free-heat
reply
    Bookmark Topic Watch Topic
  • New Topic