Assemble applications to share session data

In accordance with the Servlet 2.3 API specification, by default the Session Management facility supports session scoping by Web module. Only servlets in the same Web module can access the data associated with a particular session. WebSphere Application Server - Express provides an option that you can use to extend the scope of the session attributes to an enterprise application. Therefore, you can share session attributes across all the Web modules in an enterprise application. This option is provided as an IBM extension.

Restriction: To use this option, you must install all the Web modules in the enterprise application on a given server. You cannot split up Web modules in the enterprise application by servers. For example, with an enterprise application containing two Web modules, you cannot use this option when one Web module is installed on one server and second Web module 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 applications on which this option 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.

Servlet API Behavior: If shared HttpSession context is turned on in an enterprise application, HttpSession listeners defined in all the Web modules inside the enterprise application are invoked for session events. The order of listener invocation is not guaranteed.

Perform these steps to share session data across Web modules in an enterprise application:

  1. Start the WebSphere Development Studio Client for iSeries (WDSc).
  2. Import the EAR file if it does not already exist in the Workspace.
  3. In the J2EE Perspective, expand Enterprise Applications, and right click the application you want to modify.
  4. Select Open With --> Deployment Descriptor Editor.
  5. In the WebSphere Extensions section, select the Shared session context check box.
  6. Click File --> Save.
  7. Verify that the class definition of attributes in the session are available to all the Web modules in the enterprise application.
  8. Export the EAR file and deploy the application.