syyung6
asked on
Using Httpsession reference after session-timout?
I have a servlet class, which has a static hashtable. Whenever each request comes, i put the Httpsession reference in the hashtable. Under certain circumstances, I would make use of the Httpsession references to invalidate some session.
My question is, after the session timeout period, will the Httpsession reference be garbage collected? If so, then will the HttpSession reference be null? Or I will access some 'forbidden' area of the memory?
My question is, after the session timeout period, will the Httpsession reference be garbage collected? If so, then will the HttpSession reference be null? Or I will access some 'forbidden' area of the memory?
ASKER
Could you please explain more about WeakReference?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thank you for your help!!
and the reference is still valid.
But perhaps it will throw some exception if you want to access it.
If you use WeakReference for storing the reference to the session it will be garbag
collected and you will be able to track this with ReferenceQueue.