General J2EE: pattern for sharing HTTPSession across WebApps?
- Posted by: Nagg rao
- Posted on: January 08 2004 14:23 EST
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)
- pattern for sharing HTTPSession across WebApps? by Paul Strack on January 08 2004 18:56 EST
- pattern for sharing HTTPSession across WebApps? by Rob Misek on January 09 2004 17:00 EST
- pattern for sharing HTTPSession across WebApps? by Sean Sullivan on January 10 2004 15:30 EST
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).
yesh sounds like an idea.thank you !
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.
Tangosol Coherence: Cluster your Work. Work your Cluster.
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
Are your applications spread across multiple EAR's?
Or are the applications all kept in a single EAR?
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.