HttpSession- This is basically a map from a string key for some arbitrary value. Each time you create a session (by accessing the JSP or calling getSession()/ getSession(true)), the container will generate a unique session identifier for the string and contain a link to this object HttpSession. Again, it will use the map from the session identifier for the object HttpSession.
As soon as you put something into the session, the container contains a link to this session, and the session contains a link to your object. He will stay there for a while. There are three situations when your item will be deleted from the session:
If you explicitly delete it ( removeAttribute()or setAttribute(null))
When you have the invalidate()whole session. This basically removes all attributes and removes the entire session from the container-managed session map.
( , 2.) , /JSP (, 10 )
( ), , GC.
, HttpSessionBindingListener HttpSession, . , , , , , .
.