I have doubts in session managements. In the distributed web apps, container might do the load-balancing by taking client request and sending them out to JVM's. In these kind of web apps 1. There is one ServletContext per VM. 2.There is one ServletConfig per servlet, per VM. 3. BUT there is only one HttpSession object for given session ID per web apps, regardless the no of VM's. that means only HttpSession objects and their attributes can migrates from one VM to another.
So my question is:-- If there is only one session id given to the session object at a time then how can container recognize a particular clients based on the session ID. becouse till a particular seesion objects invalidates, all the requests are associated with the same session id. please help me out to understand this as i got stuck in this.
how can container recognize a particular clients based on the session ID
For the container it's all about requests. Either by cookie information or jsessionid request header of the request, container identify the correct session object which should associate with that request.
thanks Vijitha for your reply, But my question is how all the request are handled by the conatiner when there is only one Httpsession object with a unique session ID per web apps. when client A sends the request its sends with the particular session ID and when client B sends the request is it also sends with the same session ID??? if this so, then how container differentiate between client A and B?
But my question is how all the request are handled by the conatiner when there is only one Httpsession object with a unique session ID per web apps
No. Each different client has different HttpSession object associated in the server with unique session ID. I think you have misunderstood the statement. When a another client accesses the web app from somewhere else he gets a different HttpSession object created for him with a unique session ID.
In your 3rd statement
BUT there is only one HttpSession object for given session ID per web apps
I think they mean, only one HttpSession object for each different client per web app regardless the app is distributed among more than one JVM.
Joined: May 12, 2008
Thanks Vijitha to make me understand this.. i really appreciate your effort to clear my doubts.