Search code examples
javaspringservletsinversion-of-controlhttpsession

Is Spring session scoped bean saved in HttpSession?


Since I don't have in depth knowledge of spring session scope implementation. Can anyone please tell me if it is wise to use Spring Session scoped beans, where HttpSession object is very crucial. Like a web application where thousands of users access the site simultaneously.

Is spring session scoped bean saved in HttpSession object?

Or even if HttpSession object only refers to the spring session scoped bean, are we not making session object heavy?

How is it different form storing any bean directly in HttpSession object (making HttpSession object heavy point of view)?


Solution

  • The object is not really stored in HTTP session. It is linked with session id and actually stored inside of the Spring context. A session listener is used to clean instances once session is closed. See SessionScope JavaDoc.