This week's book giveaway is in the OCAJP 8 forum. We're giving away four copies of OCA Java SE 8 Programmer I Study Guide and have Edward Finegan & Robert Liguori on-line! See this thread for details.
We have RestFul web application, where we are using GlobalApplicationSession HASHMAP from singleton class(SessionSingleTon) to maintain user's session.
Example, whenever users send first request, we will store userObjects(its an instance with xyz properties) in GlobalApplicationSession map
The same users send a request(2nd, 3rd time) again, we will check GlobalApplicationSession map whether the userid exists, if it exists then we will get some details (from the previous session) and process the curent request.
exmaple to get previous session details.
The question is, how can we handle if the application deployed in more than one server(tomcat) using clustered and loadbalancer.
first time, user1 sends request1 and load balancer direct the request to server1. The userObjects(its an instance with xyz properties) will be stored in GlobalApplicationSession hashmap which is available in server1
2nd time, user1 sends request2 and LOAD BALANCER DIRECT THE REQUEST TO SERVER2, now GlobalApplicationSession (in server2) will not have any userObjects.