Win a copy of Beginning Java 17 Fundamentals: Object-Oriented Programming in Java 17 this week in the Java in General forum!
  • 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:
  • Tim Cooke
  • Campbell Ritchie
  • Ron McLeod
  • Liutauras Vilda
  • Jeanne Boyarsky
Sheriffs:
  • Junilu Lacar
  • Rob Spoor
  • Paul Clapham
Saloon Keepers:
  • Tim Holloway
  • Tim Moores
  • Jesse Silverman
  • Stephan van Hulst
  • Carey Brown
Bartenders:
  • Al Hobbs
  • Piet Souris
  • Frits Walraven

servlet container

 
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Ranch Hand
Posts: 8944
Firefox Browser Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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: 8944
Firefox Browser Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
a. false.
b.no. If there are no instance variable being used there is no synchronization required.
 
Ranch Hand
Posts: 1512
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Each time the server/container receives a request for a servlet, it spawns a new thread.
 
Ranch Hand
Posts: 129
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The number of potential threads spawned is controllable with SingleThreadModel and pooling limits, isn't it?
 
Ranch Hand
Posts: 3178
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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...
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic