is there a way to iterate active servlet http sessions.
or to be notified when a session is about to
be invalided/expired etc.
it'll be run by an administrative servlet every
night to make sure database resources are
released.
thx
Hi,
You can implement callbacks for your application by implementing the
methods in HttpSessionListener. You can put your notification
logic/cleanup logic in them and configure the implementation class in
your webapp's deployment descriptor.
http://tomcat.apache.org/tomcat-5.0-doc/servletapi/javax/servlet/http/HttpSessio
nListener.html
I have not come across a way to get a hold of active http sessions -
you might want to store a sessionID and related info in a database when
a session is created (using callbacks) and flag or delete the record
when it expires (again using callbacks). This will give you a handy
list of active sessions on your server, but maintaining such a db if
your website has high traffic might be tricky.
-cheers,
Manish
> is there a way to iterate active servlet http sessions.
>
[quoted text clipped - 6 lines]
>
> thx
erjdriver - 08 Sep 2006 13:34 GMT
thanks makes sense.
when you say save the session-id...wouldn't i have to save the
session objects also somewhere. because i don't think there's
a way to retrieve the object with just the session-id.
> Hi,
> you might want to store a sessionID and related info in a database [snipped]
erjdriver - 08 Sep 2006 15:22 GMT
here's a silly question.
i plan have an object that implements the
HttpSessionListener interface...
now who do i have notify of this object.
i.e. who.addSessionListener( my_new_obj )
Manish Pandit - 08 Sep 2006 21:30 GMT
You configure it in your web.xml in the <listener> tag. There is no
programmatic stuff involved once you've set it up (ofcourse you've to
implement the callbacks).
The container calls the implementation methods based on the event.
<listener>
<listener-class>your.fully.qualified.classname</listener-class>
</listener>
-cheers,
Manish
> here's a silly question.
>
[quoted text clipped - 4 lines]
>
> i.e. who.addSessionListener( my_new_obj )