Thursday, 7 February 2013

Context Attributes | Java Servlets tutorial pdf

Context Attributes

A servlet can bind an object attribute into the context by name. Any attribute bound into a context is available to any other servlet that is part of the same Web application. The following methods of ServletContext interface allow access to this functionality:
=> setAttribute
=> getAttribute
=> getAttributeNames
=> removeAttribute

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 “Sessions”), stored in a database, or set in an Enterprise JavaBeans component.

No comments: