Sharing session variables between web applications


Web tier: servlets, JSP, Web frameworks: Sharing session variables between web applications

  1. Sharing session variables between web applications (7 messages)

    If I have an EAR containing multiple WARs and set a session variable in one of the WARs, is that var accessible to the other WARs in the EAR? If so, do I have to do anything special to get the value? If not, are cookies the only way to go to acheive this?

  2. By design the sessions between different web applications cannot be shared. The JSP specification prohibits that.

    If you want to share information between web applications, you have to find a different way. Sorry if that does not help you very much, but since I did not have the necessity to share state between different web applications, I cannot help you with an out-of-the-box solution for that problem.

    Maybe it's possible to use an instance on enterprise application level, e.g. a stateful session bean or even a database table - but maybe that's too much overhead.

    Why do you need to share state variables between those applications?


  3. Sharing objects between web applications[ Go to top ]

    Ok, maybe session variables is the wrong term. I have a user object that gets created in one WAR that I need to use in another WAR in the same EAR.

    What is the best way (that isn't overly complex) to do this?
  4. I face the same problem.[ Go to top ]

    I have one EAR(main application, called MA) and one WAR(supporting application, just JIRA).

    I want to integrate JIRA with MA, since I want to use JIRA as part of my application MA. User starts from MA and when he want some extra information, he will click the link in MA and then link to JIRA.
    But MA has a session expiry checking.
    When user works with JIRA, MA should not treat he as idle. If user finally were kidded off by JIRA, the MA will also expire the session of user.

    Is there anyone could give me some light about this?
  5. If you are using WebSphere / WSAD you can do it. IBM's non-j2ee compliant way of doing this involves a file called sessionshare.xml. In this file you list the enterprise application names where you want to enable sharing. Google sessionshare.xml for more info.
  6. Because the default session implementation of session handling uses cookies you cannot access session information across contexts, browser security stops the server from sharing the cookie info.
  7. I got the following documentation on Java Forum. I hope this help.

    Best regards
  8. hmmm we can do this according to J2EE spec but has been implemented in several application servers like WebLogic, WebSphere or JBoss for example.