Assembling so that session data can be shared

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. WAS 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, 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.

Do the following to share session data across Web modules in an enterprise application...

  1. Start the Assembly Toolkit.

  2. In the Assembly Toolkit, right-click the application EAR(file) you want to share and click Open With > Deployment Descriptor Editor.

  3. In the application deployment descriptor editor of the Assembly Toolkit, 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 application (EAR) file. In the Assembly Toolkit, after you close the application deployment descriptor editor, confirm that you want to save changes made to the application.


See Also

Session management support
Problems creating or using HTTP sessions