Hi,
Both ServletContext and HttpSession objects can hold attributes. According to
Servlet 2.3 spec, the difference between the attributes in ServletContext and HttpSession is that
SRV.3.4.1 Context Attributes in a Distributed Container
Context attributes are local to the VM 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, stored in a database, or set in an Enterprise JavaBeans component..
Is there any other difference between ServletContext and HttpSession attributes which i'm missing?
Also in Servlet Spec 2.3 in Chapter 10, Application Lifecycle Events it states,
SRV.10.6 Distributed Containers
In distributed web containers, HttpSession instances are scoped to the particluar VM servicing session requests, and the ServletContext object is scoped to the web
container’s VM. Distributed containers are not required to propogate either servlet context events or HttpSession events to other VMs. Listener class instances are scoped to one per deployment descriptor declaration per Java virtual machine.
Here it says the Session is scoped to the particular VM servicing the session requests which means I cannot use sessions to store attributes to be shared, in a distributed container.
This contradicts the previous one. Which one is correct? Somebody throw lights in this.