aspose file tools*
The moose likes Servlets and the fly likes Passing session data between Servlets  residing in different machines Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Java » Servlets
Bookmark "Passing session data between Servlets  residing in different machines" Watch "Passing session data between Servlets  residing in different machines" New topic
Author

Passing session data between Servlets residing in different machines

Serdar Cabuk
Greenhorn

Joined: Aug 28, 2001
Posts: 2
Hi,
We have two servers one running a Directory Servlet in one machine and another running a Map Servlet in ANOTHER machine. I want to set some variables in session in the servlet one and retrieve it from the secnod servlet, but session data is lost in between the machines. Is there a way to pass the session data between the servlets that reside on different machines?
Thank You.
John Bateman
Ranch Hand

Joined: Mar 09, 2000
Posts: 320
Originally posted by Serdar Cabuk:
Hi,
We have two servers one running a Directory Servlet in one machine and another running a Map Servlet in ANOTHER machine. I want to set some variables in session in the servlet one and retrieve it from the secnod servlet, but session data is lost in between the machines. Is there a way to pass the session data between the servlets that reside on different machines?
Thank You.


Hi
try making yor own custom session like

Then you can Serialize your session and use it between diffrent web apps.


SOURCE CODE should be SURROUNDED by "code" tags.
Serdar Cabuk
Greenhorn

Joined: Aug 28, 2001
Posts: 2

Actually two different JVM's are running on the machines and i need a method different from the RMI. These machines do not share the same session, this is where I lose data. Something like session migration is all that i need but how?

William Brogden
Author and all-around good cowpoke
Rancher

Joined: Mar 22, 2000
Posts: 12803
    
    5
HttpSession is an interface. The typical HttpSession implementation is already serializable. The key point is that every object you store in a session must also be serializable.
Moving a session between completely different web application contexts may not be possible. To make it easier to move user data between servers, consider putting in in a database or an Object storage system and just store the unique ID in a session.
Bill
------------------
author of:
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Passing session data between Servlets residing in different machines