Win a copy of Kotlin in Action this week in the Kotlin forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Servlet Instance?  RSS feed

 
Nghiem Nguyen
Greenhorn
Posts: 25
  • Mark post as helpful
  • send pies
  • 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 ]
 
Christophe Verré
Sheriff
Posts: 14691
16
Eclipse IDE Ubuntu VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Only one (in a non-distributable environment)
 
Amit Ghai
Ranch Hand
Posts: 35
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Try this link
http://forum.java.sun.com/thread.jspa?threadID=619289&messageID=3475708
 
Dave Robbins
Ranch Hand
Posts: 131
  • Mark post as helpful
  • send pies
  • 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
 
Ben Souther
Sheriff
Posts: 13411
Firefox Browser Redhat VI Editor
  • Mark post as helpful
  • send pies
  • 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 ]
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!