If I set the attribute value in the request and after that I call session.invalidate()
, what will happen to attribute values? Will they be there still?
session. invalidate(); All objects bound to the session are removed.
Remove a particular attribute − You can call the public void removeAttribute(String name) method to delete the value associated with the particular key. Delete the whole session − You can call the public void invalidate() method to discard an entire session.
The Element method removeAttribute() removes the attribute with the specified name from the element.
Session invalidation means session destroying.So if session is destroyed,it indicates that server cant identify the client which has visited in previous.So now it creates a new session id for that client.
They will be still in memory, but they are not referenced by the HttpSession
in question anymore. I.e. they are not accessible by HttpSession
anymore.
Once the Garbage Collector runs and those objects do not have any other references by any other classes/instances, then they will ultimately be destroyed and free memory.
request and sessions are two different things. attributes set in request will be available until you serve the request. Once done all values will be vanished.
Attributes in session will be there until session gets expired or you call invalidate explicitly. Either of these will kill the current session and create a new one on next request onwards.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With