File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Servlets and the fly likes Servlet Instance Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Servlets
Bookmark "Servlet Instance" Watch "Servlet Instance" New topic

Servlet Instance

sai prasanna
Ranch Hand

Joined: May 02, 2005
Posts: 167
Hai all
If i had a servlet and 100 clients are requesting that servlet how many instances are created ? According to my analysis
init() method is initialized once and the service() method executes for each clients request so the servlet has one instance serving
100 clients.

thanks in advance
Sunny Kumar
Ranch Hand

Joined: Oct 27, 2005
Posts: 57
Only one instance is created and any new request by client generates a new thread which handles the client requests.
ramprasad madathil
Ranch Hand

Joined: Jan 24, 2005
Posts: 489

This is container specific. A container may choose to have, say, 50 threads per instance and when the number of current requests exceeds that, may create another instance. The exact number of instances and thread per instance is not cause for concern.

I agree. Here's the link:
subject: Servlet Instance
It's not a secret anymore!