aspose file tools*
The moose likes Web Component Certification (SCWCD/OCPJWCD) and the fly likes Servlet instances Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Certification » Web Component Certification (SCWCD/OCPJWCD)
Bookmark "Servlet instances" Watch "Servlet instances" New topic
Author

Servlet instances

Mathew Sam
Ranch Hand

Joined: Dec 19, 2001
Posts: 124
Will it be same servlet instance servicing the request if access it through either servlet class name or servlet-name in web.xml or url-pattern defined in web.xml ?
regards,
Sam
Engin Okucu
Ranch Hand

Joined: Feb 09, 2002
Posts: 174
Hi Mathew,
It will be different instance. In first, when you start your web server, the web-server will create one servlet instance for the servlet that you defined in your web.xml.
But if your want to acces to your servlet with the package's name, then your 're creating an other instance of your servlet. If you had defined parameters for your servlet in web.xml then you won't be able to access to these parameters because you had defined these parameters for the servlet that you had defined in web.xml not for the servlet with the package's name
I hope it can help you.
Anthony Villanueva
Ranch Hand

Joined: Mar 22, 2002
Posts: 1055

SRV.2.2 Number of Instances
The servlet declaration which is part of the deployment descriptor of the web 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.
In the case where a servlet was deployed as part of an application marked in the deployment descriptor as distributable, a container may have only one instance per servlet declaration per virtual machine (VM). However, if the servlet in a distributable application implements the SingleThreadModel interface, the container may instantiate multiple instances of that servlet in each VM of the container.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Servlet instances