• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

servlet container

 
Rowan John
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
I was wondering whether the Servlet Container spawns instances of servlets (ie the Struts Servlet Controller) to handle http requests much like an EJB Container does with stateless session beans? I'm assuming it doesnt due to the HTTP session object?
If the Servlet Container does not spawn new instances of a Servlet Controller and you synchronise your servlets methods this to me would become a bottleneck to the application?

thanks in advance,

Rowan
 
Pradeep bhatt
Ranch Hand
Posts: 8927
Firefox Browser Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Usually there will be one instance. Yes, synchorinizations are bottlenecks.
[ November 12, 2003: Message edited by: Pradeep Bhat ]
 
Rowan John
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I realize that synchronizations are bottlenecks, but my question is:
a) Does the servelt container spwan new instances of Servlets to handle concurrent requests (like EJB stateless session beans)?
b) Is is considered bad programming practice to not synchronize the methods of the Servlet if the methods arent using any instance variables?

thanks,
Rowan
 
Pradeep bhatt
Ranch Hand
Posts: 8927
Firefox Browser Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
a. false.
b.no. If there are no instance variable being used there is no synchronization required.
 
Bosun Bello
Ranch Hand
Posts: 1510
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Each time the server/container receives a request for a servlet, it spawns a new thread.
 
Darryl Failla
Ranch Hand
Posts: 129
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The number of potential threads spawned is controllable with SingleThreadModel and pooling limits, isn't it?
 
Ko Ko Naing
Ranch Hand
Posts: 3178
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Bosun Bello:
Each time the server/container receives a request for a servlet, it spawns a new thread.

Yes, I agree with Bosun... a new thread is always created to deal with concurrent requests...
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic