Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Passing session data between Servlets residing in different machines

 
Serdar Cabuk
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 320
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.

 
Serdar Cabuk
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

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
Posts: 13061
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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:
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic