Assembling so that session data can be shared


 

+

Search Tips   |   Advanced Search

By default, the Session Management facility supports session scoping by Web module in accordance with the Servlet 2.3 API specification. Only servlets in the same Web module can access the data associated with a particular session. However, we can use the IBMApplicationSession object or the IBM extension, shared session context, to share data outside of the Web module scope.

The IBMApplicationSession object is the recommended method for sharing session attributes. The IBM extension, shared session context, is deprecated.

The IBMApplicationSession object is a parent session object that can be retrieved by a Web module's session and can share session attributes across all of the Web modules in a business-level application.

The default scope of the business-level application is the enterprise application.

The shared session context option extends the scope of the session attributes as well. Using the shared session context extension, there is only one session object for the entire business-level application or for the default enterprise application.

For a shared session for a business-level application, the class files for all objects placed in the session must exist in an isolated shared library and be common among all applications.

The benefit to using the ApplicationSession method is that each Web module can maintain its own session as well as have a reference to the shared session.

If we're migrating an application from a previous version of WAS ND, the ApplicationSession method requires a change to the application logic of the application.

Restriction:

To use a shared session, install all applications within a business-level application on a given server.

We cannot split up the enterprise application by servers. For example, we cannot use this option when one enterprise application in BLA1 is installed on one server and a second enterprise application also in BLA1 is installed on a different server.

In such split installations, applications might share session attributes across Web modules using distributed sessions, but session data integrity is lost when concurrent access to a session is made in different Web modules. It also severely restricts use of some Session Management features, like TIME_BASED_WRITES.

For enterprise apps on which this shared session context extension is enabled, the Session Management configuration on the Web module inside the enterprise application is ignored. Then Session Management configuration defined on enterprise application is used if Session Management is overwritten at the enterprise application level. Otherwise, the Session Management configuration on the Web container is used. If using multiple enterprise apps within a business-level application, the session management configuration must be common among all applications and Web modules within this business-level application.

 

Servlet API Behavior

HttpSession listeners defined in all the Web modules inside the business-level application or enterprise application are invoked for session events. The order of listener invocation is not guaranteed.

Do the following to share session data across the business-level application.

  1. Do the following to share session data using the IBMApplicationSession object within the application code.

    1. Retrieve the session object

      HttpSession session = request.getSession();

    2. Cast this object to an IBMSession object and call the getIBMApplicationSession method.

      IBMApplicationSession appSession = ((IBMSession)session).getIBMApplicationSession();

    3. Use the appSession like a normal session object.

  2. Do the following to share session data using the Shared session context extension.

    1. Start an assembly tool.

    2. In the assembly tool, right-click the EAR file to share and click Open With > Deployment Descriptor Editor.

    3. In the application deployment descriptor editor of the assembly tool, select Shared session context under WebSphere Extensions.

      Make sure the class definition of attributes put into session are available to all Web modules in the enterprise application. The shared session context does not fully meet the requirements of the specifications.

    4. Save the EAR file.

      In the assembly tool, after you close the application deployment descriptor editor, confirm to save changes made to the application.

 

Related

HTTP session problems
Session management support
Business-level applications
Assembly tools