Rajani Gummadi wrote:Hi,
In both the cases, distributed and non-distributed, it seems there is only one context per virtual machine. So how are these two things different.
Does the distributed web app, having several instances running on different nodes, share the same virtual machine.
My material for SCJP (2008), SCWCD (2010), SCBCD (2010). About me
Rajani Gummadi wrote:Hi,
I was reading through the api for "ServletContext" at ...... running on different nodes, share the same virtual machine.
My material for SCJP (2008), SCWCD (2010), SCBCD (2010). About me
Rajani Gummadi wrote:Hi,
I was reading through the api for "ServletContext" at http://download.oracle.com/javaee/1.4/api/javax/servlet/ServletContext.html and it says
"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. In this situation, the context cannot be used as a location to share global information (because the information won't be truly global). Use an external resource like a database instead. "
In both the cases, distributed and non-distributed, it seems there is only one context per virtual machine. So how are these two things different.
Does the distributed web app, having several instances running on different nodes, share the same virtual machine.
Don't use context attributes to share state between servlets--Context attributes are stored in ServletContext and are shared by all servlets in a Web application. But context attributes are specific to the JVM instance in which they were created. Servlets that communicate by sharing context attributes may not operate properly if distributed, because context attributes do not replicate between Web containers in different JVM instances. To share data between distributed servlets, place the data in a session object, store it in the EIS tier in a database or distributed cache, or use an enterprise bean.
One exception to this guideline is to use context attributes as a shared data cache between the servlets in each Web container. Cache hits and misses affect only an application's performance, not its behavior.
|BSc in Electronic Eng| |SCJP 6.0 91%| |SCWCD 5 92%|
Oh sure, it's a tiny ad, but under the right circumstances, it gets bigger.
New web page for Paul's Rocket Mass Heaters movies
https://coderanch.com/t/785239/web-page-Paul-Rocket-Mass
|