Sharing session between multiple wars in the same EAR (For WebSphere Applications)

To share the same session between multiple wars in the same ear, you can do this if you are using IBM Rational Application Developer (RAD) or Rational Software Architect (RSA). For this example, Iam using RSA 7.5.

Assume that you set a session attribute (key) to a value (xyz) in application1 war as follows:

session.setAttribute("key", "xyz");

Using this feature, you can get this session attribute in application2 war using:

session.getAttribute("key");

To enable this feature in the EAR:
1. Open the (ibm-application-ext.xml), if you did not find this file in your EAR, just select the EAR (Java EE -> Generate WebSphere Extensions Deployment Descriptor).

2. Check the (Shared Session Context) option as follows:

This is about all!

This entry was posted in WebSphere by hazems. Bookmark the permalink.

About hazems

Hazem Saleh has more than eleven years of experience in Cloud, Mobile and Open Source technologies. He worked as a software engineer, technical leader, application architect, and technical consultant for many clients around the world. He is an Apache PMC (Project Management Committee) member and a person who spent many years of his life writing open source software. Beside being the author of the "JavaScript Unit Testing" book, "JavaScript Mobile Application Development" book, "Pro JSF and HTML5" book and the co-author of the "Definitive guide to Apache MyFaces" book, Hazem is also an author of many technical articles, a developerWorks contributing author and a technical speaker in both local and international conferences such as ApacheCon North America, Geecon, JavaLand, JSFDays, CON-FESS Vienna and JavaOne. Hazem is an XIBMer, he worked in IBM for ten years. Now, He is working for Nickelodeon New York as a Mobile Architect. He is also an OpenGroup Master Certified Specialist.