File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Servlets and the fly likes Pattern for coordinating Session Timeouts between Web Applications Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Servlets
Bookmark "Pattern for coordinating Session Timeouts between Web Applications" Watch "Pattern for coordinating Session Timeouts between Web Applications" New topic
Author

Pattern for coordinating Session Timeouts between Web Applications

David Howie
Greenhorn

Joined: Jan 26, 2010
Posts: 11
We have requirements to coodinate HTTP session timeouts between web applications that are deployed in separate EARs. There is no need to share session data.

We have a couple of Internet facing web applications. The two web applications share the same look and feel and provide links between each other. To the user they appear to be one application, but they are indeed separate applications with separate context roots. Once the user establishes a session with each application, then we want the sessions to remain active in both applications as long as there is activity in at least one of the applications. This way if the user spends an inordinate amount of time in one app, then links back to the other the user's session will still be alive in the other application.

Our current thoughts are a servlet filter that would send a simple "keep alive" type HTTP request from one web application to the other web application. But I'm not sure how the session id comes into play here, in ensuring that the receiver of the "keep alive" request recieves the correct session id or any session id at all. I've been told by the teams that own the applications that are in need of this solution that although they are two separate web apps with their own session data, they both get the same session id when accessed from the same browser instance, does that sound right?

Does anyone have a recommended pattern for implementing such a solution and any insight to the session id management?

BTW...This is a WebSphere 6.1 environment, soon to be migratined to WebSphere 7.0.

Thanks
Nauman Hasan
Ranch Hand

Joined: Jul 27, 2005
Posts: 34
That should work or you could do a reverse proxy in front which takes care of the session management. (not a Java solution though)

~Nauman
ramprasad madathil
Ranch Hand

Joined: Jan 24, 2005
Posts: 489

Our current thoughts are a servlet filter that would send a simple "keep alive" type HTTP request from one web application to the other web application. But I'm not sure how the session id comes into play here, in ensuring that the receiver of the "keep alive" request recieves the correct session id or any session id at all. I've been told by the teams that own the applications that are in need of this solution that although they are two separate web apps with their own session data, they both get the same session id when accessed from the same browser instance, does that sound right?


Are the 2 session objects the same too? Do the applications use the standard J2ee session maintenance mechanisms?

An easier mechanism would be to have a keep-alive on the browser. Each application when it loads on the browser can request a 1 pixel image from the other application (or it could make an ajax call to the other application) which would ensure that the session is kept alive on the other application. This 1 pixel image request can be embedded inside a header (or footer) page so that it is automatically included in every page.

cheers,
ram.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Pattern for coordinating Session Timeouts between Web Applications