[Help] Detecting when a session is expiring, and being able to do something useful about it...

R

Russ Perry Jr

I'm looking into ways of removing users from a list when their sessions
expire. I haven't been able to find a lot of good info though, so I'm
hoping maybe somebody here will have some pointers.

I found this article: http://www.sys-con.com/story/?storyid=37412&DE=1

It says "adding the javax.servlet.http.HttpSessionListener interface to
the story, as illustrated in Listing 1*, helps you deliver login
management that runs with browsers that don't have cookies or JavaScript
enabled", and that looks sort of attractive.

[* http://photos.sys-con.com/story/res/37412/source.html]

However, a discussion on this page:
http://saloon.javaranch.com/cgi-bin/ubb/ultimatebb.cgi?ubb=get_topic&f=18&t=000652

....and others seems to indicate that by the time HttpSessionListener's
sessionDestroyed() method runs, the session object is empty, so you
can't recover even the ID to identify what session expired.

Moreso, the documentation for HttpSessionListener says "To recieve
notification events, the implementation class must be configured in
the deployment descriptor for the web application." but I'm not sure
how/where to put/connect the implementing class, nor can I find examples
of what to put in web.xml, which I'm assuming is what they mean by
"deployment descriptor for the web application" (and my apologies if
I'm way off here).

The javaranch link also mentions a "wrox example", but I'm having no
luck finding it online. Is this perhaps only in a book, or does anyone
know where I can find said example online?

Can anyone help? We're using JBuilder to build our struts app, and
aren't using anything like LDAP, JAAS, etc. Pretty basic and plain
jane.
 
R

Russ Perry Jr

I'm looking into ways of removing users from a list when their sessions
expire. [...HttpSessionListener...]

I hate following my own posts, but I found a site saying that the
sessionDestroyed() method of the HttpSessionListener was fixed to not have
a null HttpSession to refer to in Servlet 2.4. I was told we're only on
2.3, but it works! So anyone else out there having the same problem might
try at least 2.3 and possibly 2.4.

Heh, yesterday was almost all research, but today I have the login and
logout stuff pretty much where we want it. How nice to be productive!
:)
 

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,578
Members
45,052
Latest member
LucyCarper

Latest Threads

Top