Here is the doubt I have come up with ServletContext is one per web-app and one per JVM. But if I am running more than one web-app on the same JVM. Then it has 2 ServletContext per JVM. Is it Possible? Can anybody elaborate on this?
Each webapp will have its own ServletContext. The way the api docs put it is, "There is one context per "web application" per Java Virtual Machine. (A "web application" is a collection of servlets and content installed under a specific subset of the server's URL namespace such as /catalog and possibly installed via a .war file.)"
The "per web application" part means that if you set up the application in a cluster then each node in the cluster has a separate JVM, and that JVM will be running separate copies of all the applications, including a ServletContext for each webapp.
There is one context per "web application" per Java Virtual Machine.
That means each web application has exactly one ServletContext
on each VM. (The multiple-VM case is when you have a distributed application)
Just to avoid the confusion, you can think of a servlet context as an application context.
To answer your question, yes multiple applications can be loaded in a single JVM. AFAIK, Tomcat creates different class loader per application. So, the class loader instances per application in a single JVM. When a context needs to be redeployed, the entire web application class loader is discarded, and a brand new instance is created to load all the classes for this web application.
So, it means that there is exactly one servlet context per web application per JVM. It doesn't infer that there is exactly one application per JVM.
For more read Tomcat 6 Servlet Container: Overview.
One per web application and one per JVM can be explained with the following tables.
Several Web Apps on one Server (one JVM):
Web App A - Server/JVM 1 - Context 1
Web App B - Server/JVM 1 - Context 2
Web App C - Server/JVM 1 - Context 3
Same Web App on several Servers (several JVMs):
Web App A - Server/JVM 1 - Context 1
Web App B - Server/JVM 1 - Context 2
Web App C - Server/JVM 1 - Context 3
Web App C - Server/JVM 2 - Context 4