wood burning stoves 2.0*
The moose likes Servlets and the fly likes Parameterizing a Servlet in web.xml and Running Instances Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » Servlets
Bookmark "Parameterizing a Servlet in web.xml and Running Instances" Watch "Parameterizing a Servlet in web.xml and Running Instances" New topic
Author

Parameterizing a Servlet in web.xml and Running Instances

Cameron Wallace McKenzie
author and cow tipper
Saloon Keeper

Joined: Aug 26, 2006
Posts: 4968
    
    1

Servlets are great, because one instance services an innumerable amount of clients. However, I was wondering (and am too lazy to read the spec).

When a single Servlet class is parameterized in the web.xml file, to create say three different servlet definitions, at runtime, will one instance be created, but run with the appropriate parameterization to make it seem like there are three instances, or is there a definite one to one relationship between servlet definitions in the web.xml file, and instances running.

Remember, I'm talking about the same Java class file, just parameterized differently three times in the deployment descriptor.

Just wondering.

Thanks,

-Cameron McKenzie
Ben Souther
Sheriff

Joined: Dec 11, 2004
Posts: 13410


SRV.2.2 Number of Instances
The servlet declaration which is part of the deployment descriptor of theWeb application
containing the servlet, as described in Chapter SRV.13, �Deployment
Descriptor�, controls how the servlet container provides instances of the servlet.
For a servlet not hosted in a distributed environment (the default), the servlet
container must use only one instance per servlet declaration. However, for a servlet
implementing the SingleThreadModel interface, the servlet container may
instantiate multiple instances to handle a heavy request load and serialize requests
to a particular instance.




[ December 28, 2006: Message edited by: Ben Souther ]

Java API J2EE API Servlet Spec JSP Spec How to ask a question... Simple Servlet Examples jsonf
 
 
subject: Parameterizing a Servlet in web.xml and Running Instances
 
Similar Threads
Is init() really called once
web.xml in distributed env.
One clarification needed regarding Servlet
why cant there be multiple servlets running at the same time?
Multiple Servlet Instance?