In your case. I would bet that you are going to get a new session every request.
It might be a better idea having your Session created in a Filter and placed into the ThreadLocal. Then your action doesn't need to worry about opening a new session, it just uses the one found in the ThreadLocal. The filter would then close the session when the request to the server is completed.
I believe this is called the one session per request pattern. Not positive though. But it is quite popular for web development.
Joined: Jul 11, 2006
can you tell me how to maintain old session to track the same user's information.After sending the response the session will be lost ,then how to track the same user in the next request.
Please let me know, if i am using struts and using hibernate util class to open and close session: Where to open and where to close session and how to track for multiple requests of same user.