This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
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 Android Security Essentials Live Lessons this week in the Android 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: 12761
    
    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:
 
 
subject: Passing session data between Servlets residing in different machines
 
Similar Threads
web container on mutiple jvms
Passing request params from one servlet to another servlet running in different app s
servletContext()
question on servlet contexts
Comunicate two Applications in one machine in Java