Clustering and Load Balancing in Tomcat 5, Part 2
Subject:   Session replication requirements
Date:   2004-04-16 13:19:50
From:   jeffhuff
I think in WebLogic, in order to get it to replicate your Serializable session object to the other clustered servers, you have to set the attribute back into the session if you modify it.

Session session = request.getSession(false);
Map items = (Map)session.getAttribute("items");
items.put("new", new String("new"));

won't do it, you have to

session.setAttribute("items", items);

This seems to be the only way that the session would know that something changed.

Are there any good patterns to ensure that developers don't forget to set it back into the session instead of relying on modifying the reference?

Thanks for the article.