The answer is going to be specific to the type of server you are using. An application server is not required to support distributed applications, but most do.
Basically, servers that support load balancing and clusters maintain session information in some type of datastore that each cluster machine can access. If a request comes into a machine, and its session exists on a different machine, the container will migrate the session to the machine servicing the new request.
The key point here is that there is only one session per distributed application, and the application server handles all of the migration for you. You can use an HttpSessionActivationListener if you want trigger events when the session is migrated.
“Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning.” - Rich Cook
Joined: Jun 30, 2005
You can also serialize session data onto a disk and allow a different machine reload that data. ... However, as mentioned above, it's server specific. -stan