This week's book giveaway is in the OO, Patterns, UML and Refactoring forum. We're giving away four copies of Refactoring for Software Design Smells: Managing Technical Debt and have Girish Suryanarayana, Ganesh Samarthyam & Tushar Sharma on-line! See this thread for details.
I am developing a web site using JSP's that will be provided from tomcat running on 2 web servers with the load distributed by a load sharing switch. This means that any one request could go to either server and so to either one of 2 (or more) JVM's. I need to save information about a clients session.
If this was running on 1 web server I would save the data as an object in the HttpSession (ie. using the request.getSession().setAttribute and request.getSession().getAttribute methods). In the API doc it has one slightly criptic phrase  "When container migrates a session between VMs in a distributed container setting, all session attributes implementing the HttpSessionActivationListener interface are notified." This seems to indicate that in my situation it is possible to access the same instace of HttpSession across 2 or more JVM's though I am not sure how this would be done (perhaps by serializing the data in a cookie?). Unfortunatly the load bearing switch is not yet set up so I cannot test it before I start coding.
Does anyone know if it is possible to share session data in this way? Thanks for any help.
Yes, Tomcat supports clustering via session replication.
If you poke around a bit, you should be able to find some articles on the web that show you how to use an instance of the Apache Web Server (httpd) as front end to a cluster of Tomcat nodes. This is one way you could test this before your switch is up and running.
Since this is really more of a Tomcat question than a JSP one, I'm going to move this to our Tomcat forum.