Win a copy of Microservices Testing (Live Project) this week in the Spring forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • Ron McLeod
  • Jeanne Boyarsky
  • Paul Clapham
Sheriffs:
  • Liutauras Vilda
  • Henry Wong
  • Devaka Cooray
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Al Hobbs
  • Carey Brown
Bartenders:
  • Piet Souris
  • Mikalai Zaikin
  • Himai Minh

Passing session data between Servlets residing in different machines

 
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Ranch Hand
Posts: 320
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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?

 
Author and all-around good cowpoke
Posts: 13078
6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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:
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic