• 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
  • Ron McLeod
  • Rob Spoor
  • Tim Cooke
  • Junilu Lacar
Sheriffs:
  • Henry Wong
  • Liutauras Vilda
  • Jeanne Boyarsky
Saloon Keepers:
  • Jesse Silverman
  • Tim Holloway
  • Stephan van Hulst
  • Tim Moores
  • Carey Brown
Bartenders:
  • Al Hobbs
  • Mikalai Zaikin
  • Piet Souris

Behaviour of HttpSession across multiple instances of tomcat

 
Greenhorn
Posts: 23
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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 [1] "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.

Hugh

[1] http://java.sun.com/javaee/5/docs/api/javax/servlet/http/HttpSession.html
 
Sheriff
Posts: 13411
Firefox Browser VI Editor Redhat
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Ben Souther
Sheriff
Posts: 13411
Firefox Browser VI Editor Redhat
 
Huw Morgan
Greenhorn
Posts: 23
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thank you very much, that answers my question.
 
You showed up just in time for the waffles! And this tiny ad:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
reply
    Bookmark Topic Watch Topic
  • New Topic