Link to home
Start Free TrialLog in
Avatar of syyung6
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?
Avatar of superschlonz
superschlonz

As long as you have a reference to the session object it will not be grabage collected
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.
Avatar of syyung6

ASKER

Could you please explain more about WeakReference?
ASKER CERTIFIED SOLUTION
Avatar of superschlonz
superschlonz

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of syyung6

ASKER

Thank you for your help!!