pattern for sharing HTTPSession across WebApps?


General J2EE: pattern for sharing HTTPSession across WebApps?

  1. pattern for sharing HTTPSession across WebApps? (6 messages)

    Problem scenario:
    1)User logs in to a Web App
    2)Accesses some information.
    3)Use case demands that this Web Application interact with another Web-Application (through a hyper link /servlet call) located in the same Application server

    Ho do we share HTTPSession information

    (apart from storing stuff as Cookies , in HTTP header and CGI/HTML hidden elements)
  2. Try this:

    1. Use the ServletContext.getContext(contextPath) to retrieve the context for the other web application.

    2. Get a request dispatcher to the other context, targeting a ShareSessionServlet in the other Web Application.

    3. Extract session data, and store it the request as request attributes.

    4. Forward the request to the ShareSessionServlet in the other web app. Copy session data back out of the request and into the session of the other web application.

    I suggest you don't copy all the session data. Just copy what you need (probably security credentials).
  3. yesh sounds like an idea.thank you !
  4. Hi Nagraj,

    Another approach to accomplish this as well as providing the utmost in high availability and fault-tolerance of you http session data would be to use Coherence*Web included in the latest build of Coherence. This allows the use of all the different caching strategies supported by Coherence (i.e. Replicated, Distributed/Partitioned, Near/Distributed, Overflow to Disk, Write-Behind to a datastore, etc.) to manage/store you session data.

    Rob Misek
    Tangosol Coherence: Cluster your Work. Work your Cluster.
    Coherence Forums.
  5. Coherence might have been an option but its too late now since we are in the middle of our project and its too risky to change/redefine and introduce an extra piece in the architecture
  6. Are your applications spread across multiple EAR's?

    Or are the applications all kept in a single EAR?
  7. I have application in different ears deployed in different instances of application server on the same box. I like to find out a way to do session sharing among thoes applications including session time-outs.
    Any ideas??