aspose file tools*
The moose likes Servlets and the fly likes servlet container Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Servlets
Bookmark "servlet container" Watch "servlet container" New topic
Author

servlet container

Rowan John
Greenhorn

Joined: Oct 12, 2003
Posts: 14
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

Joined: Feb 27, 2002
Posts: 8919

Usually there will be one instance. Yes, synchorinizations are bottlenecks.
[ November 12, 2003: Message edited by: Pradeep Bhat ]

Groovy
Rowan John
Greenhorn

Joined: Oct 12, 2003
Posts: 14
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

Joined: Feb 27, 2002
Posts: 8919

a. false.
b.no. If there are no instance variable being used there is no synchronization required.
Bosun Bello
Ranch Hand

Joined: Nov 06, 2000
Posts: 1510
Each time the server/container receives a request for a servlet, it spawns a new thread.


Bosun (SCJP, SCWCD)
So much trouble in the world -- Bob Marley
Darryl Failla
Ranch Hand

Joined: Oct 16, 2001
Posts: 129
The number of potential threads spawned is controllable with SingleThreadModel and pooling limits, isn't it?


Darryl Failla
Sun Certified Java 2 Programmer
Ko Ko Naing
Ranch Hand

Joined: Jun 08, 2002
Posts: 3178
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...


Co-author of SCMAD Exam Guide, Author of JMADPlus
SCJP1.2, CCNA, SCWCD1.4, SCBCD1.3, SCMAD1.0, SCJA1.0, SCJP6.0
 
 
subject: servlet container