This week's book giveaway is in the OCAJP 8 forum. We're giving away four copies of OCA Java SE 8 Programmer I Study Guide and have Edward Finegan & Robert Liguori on-line! See this thread for details.
Hi, Excerpt taken from Servlet spec 2.3 . question below For a servlet not hosted in a distributed environment (the default), the servlet container must use only one instance per servlet declaration. 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). I do not understand the difference between a servlet marked distributalble and the default(which is not distributable) in the context of number of servlet instances. to sum it up Not Distributable - 1 instance Distributable - 1 instance/vm whats the difference between one instance and one instance/vm, it sounds the same to me.
It is the same, *IF* you are talking about a single instance of your web container. (marking something 'distributable' in a single-container environment has no effect).
Imagine for a moment that you are writing an application that will never run anywhere but your local box. Or your one single web server in your hosting company's data center. This is the case you are thinking of. This is the case where it makes no difference.
But what if you wrote an application that was for 'enterprise' and needed redundancy. Or what if it was to serve a site as huge as www.cnet.com or slashdot. You'd need scalability.
The way we do these kinds of things is by using more than one web container, and having these multiple containers share the load.
Assume two containers: In this case there is a big difference between "one instance" and "one instance per vm". The spec states that while there may be two instances of the servlet (by virtue of there being two containers)... there is still only one PER container.
However, I just saw what is a potentially confusing point in the spec. 'Container' in my mind usually equates to a single VM. If there are two instances of the container, that's two VM's. But the spec doesn't implicitly limit a container to a single VM. The point here is, that for some 'enterprise' level systems, there might be a fuzzy boundary between what a 'container' is and what a VM is. eg: iPlanet's kas/kxs process might be a 'container' that contains two VM's (called kjs processes).
The thing to remember is "one instance per VM only and always"
And of course, this entire discussion only applies to those servlets that don't implement SingleThreaded model.