SRV.4.3 Context Attributes


A servlet can bind an object attribute into the context by name . Any object 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

SRV.4.3.1 Context Attributes in a Distributed Container

Context attributes exist locally in the VM in which they were created and placed. This prevents the ServletContext from being used as a distributed shared memory store. If information needs to be shared between servlets running in a distributed environment, that information should be placed into a session (see Chapter SRV.7, "Sessions"), a database, or set in an Enterprise JavaBean.



Java 2 Platform, Enterprise Edition. Platform and Component Specifications
Java 2 Platform, Enterprise Edition: Platform and Component Specifications
ISBN: 0201704560
EAN: 2147483647
Year: 2000
Pages: 399

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net