Win a copy of Think Java: How to Think Like a Computer Scientist this week in the Java in General forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Session object in cluster environment

 
Naeva Darley
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The problem scenario is:
In a cluster environment, an object is saved in session by one node, and then one of that saved object's attribute is updated as follows:
1. session.setAttribute(ObjectName, value);
2. ObjectName sessObject = (ObjectName)session.getAttribute(ObjectName);
3. sessObject.updateAttribute1(); //which updates attribute1 of sessObject
Then the failover scenario occurs where the request is sent to the other node. Now, we don't see the updated attribute of the saved session object when the 2nd node tries to process it.

My question is, do we need to explicitly set the object in session again every time there is an attribute change? I mean, do we need to have the following setAttribute line everytime we update any attribute of that object to keep the session object up to date?
session.setAttribute(ObjectName, value);
 
Ben Souther
Sheriff
Posts: 13411
Firefox Browser Redhat VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Naeva
Welcome to JavaRanch!

We're pleased to have you here with us in the Servlets forum, but there are a few rules that need to be followed, and one is that proper names are required. Please take a look at the JavaRanch Naming Policy and adjust your display name to match it.

In particular, your display name must be a first and a last name separated by a space character, and must not be obviously fictitious.

You can change it here
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic