Hi, If I have 2 jvms in my cluster, will I have two servletcontext objects? If I set attribute in application scope(servlet context) and it sets in one jvm then can I get the same value from other jvm's servlet context, if it happens to go to the next jvm in my next call? Please clarify. Thanks in advance.
In the clustered environment you can only share the session data within servers and this process will take care by your manager class that you declared in server.xml. so if there any method to get servlet context from session then you can. but i dont think there is any,
I can speak with WebSphere experience, where the ServletContext is not synchronized across JVMs. The ServletContext should be used for objects that are largely read, and rarely written to, and when they are written to, a lack of synchronization across ServletContexts will not be detrimental to the JVM.
A good job for an object in a ServletContext is a component that marshals requests to an underlying central database. The object can always easily be pulled from the ServletContext, but the actual DATA is pulled from a central location, ensuring the data is always in sync.
Also, be careful of the size of the objects you put into the ServletContext. You don't want the ServletContext eating up too much of your memory.
Joined: Nov 29, 2005
Below text I have taken from servlet spec. SRV.3.4.1 Context Attributes in a Distributed Container Context attributes are local to the JVM in which they were created. This prevents ServletContext attributes from being a shared memory store in a distributed container. When information needs to be shared between servlets running in a distributed environment, the information should be placed into a session (See Chapter SRV.7, Sessions), stored in a database, or set in an Enterprise JavaBeansTM component.
I’ve looked at a lot of different solutions, and in my humble opinion Aspose is the way to go. Here’s the link: http://aspose.com