Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / General / September 2006

Tip: Looking for answers? Try searching our database.

iterating active java sessions

Thread view: 
erjdriver - 07 Sep 2006 23:12 GMT
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
Manish Pandit - 08 Sep 2006 04:18 GMT
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 )


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.