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.)
In the case of a web application marked "distributed" in its deployment descriptor, there will be one context instance for each virtual machine
Yes, each application is identified by its unique "context root". You can't have two applications at the same context root as then the container wouldn't know which application to send requests to. However, you can use the same container for applications installed to www.mydomain.ext, sub.mydomain.ext etc. for all subdomains and any other domains you wish, and also for paths within those domains. For example you can have two different applications installed under the domain mysite.com, then you could have mappings to / and /forum in the same container each to different Web applications.
1. Is it possible to have more than one web application in single Servlet Container?
A distributed application is one which is deployed on several application servers simultaneously - picture several identical servers lined up side-by-side each with an identical copy of the Web application. Then requests from clients can be sent (or "farmed") to any one of those running applications. The advantage is only apparent in enterprises with high volumes of traffic; in this case the group of servers is referred to as a "cluster" and helps to perform "load balancing". This means that clients are not dependent on just one machine to do all the processing of the thousands of requests; instead you can delegate to a machine that's currently doing less work, and therefore improving response-serving times. Unless you work with high-volumes, with hundreds of simultaneous users and requests, this never becomes an issue.
2. What is a "distributed" web application? I mean can u gimme a scenario so that i can appreciate the concept?
In general, J2EE Web servers (or just servlet containers like Tomcat) are built using Java... this means they are actually running inside their own JVM instance. Hence there is only one JVM running, and it is actually started before the server (so in this case, the server doesn't load the JVM - it's already running). However, if you have multiple servers (and therefore containers) then you will also have multiple JVMs. So the statement "This is one context per Web application per JVM" essentially reduces to the statement that each application in a single container has only one context associated with it (indeed the converse that "each context is associated with only one application" is also true); however, there is the possibility that a single machine may have multiple JVMs (or containers) running on it. In that case, since one JVM instance is isolated (at least in memory allocation) from another, there must be a separate context in each JVM. Hence the statement that "there is only one context per Web application", but clarified by "per JVM" in case there are multiple.
3. Since the Server loads the JVM, which later runs the servlet container....right? If yes, than why does the statement read "There is one context per "web application" per Java Virtual Machine.? Does it mean that a sngle Web server can load more than one JVM and hence there will be more than one Servlet Container?
Originally posted by Reshma Pai:
Answer to 1.) NO
posted by Reshma Pai:
Answer to 1.) NO
In general, J2EE Web servers (or just servlet containers like Tomcat) are built using Java... this means they are actually running inside their own JVM instance.
An example of this type (author is talking abt In-Proces servlet containers) is Tomact running inside Apache Web Server. Apache loads a JVM that runs Tomcat. In this case, the web server handles the static content by itself, and Tomcat handles the servlets and JSP pages.....
The author is correct... Apache is a (non-Java) Web server. In order to execute a Java Web server (in this case Tomcat), Apache has to start Tomcat, but Tomcat needs a JVM to run in (just like any other Java application). So Apache implicitly loads a new JVM as the first step towards starting Tomcat.
So is the author wrong in saying that Apache loads a JVM?
I was under the impression that Session Migration is generally done when a server fails over and requests have to be transferred to a new server.
Is it also done just to handle excess traffic like transferring older sessions to a new server and just handling newer sessions.
I thot the newer sessions would be transferred as in the first request itself would go to the other server in the cluster ??
Am I missing something here or is there a specification for this behavior..?
You showed up just in time for the waffles! And this tiny ad:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koophttps://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton