That will depend on the application server you are dealing with.
I happen to be familiar with IBM WebSphere Application Server. As an administrator, you can switch on session replication across the running instances of your distributed application (and there are different options with different performance/failover trade-offs). You also have some configuration to do in the associated web server (usually IBM Http Server).
I don't know the answer for open source application servers, but I think you will find plenty of resources to help you. Here is a thread which talks about clustering with Tomcat (as the web container) and Apache (as the web server): ServerSide.com discussion on Tomcat / Apache clustering
Whichever tools you are using, you shouldn't have to alter your coding approach - the session object should be up-to-date and available to whichever running instance your requests go to.