File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Servlets and the fly likes Session Listener not getting invoked Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Java Interview Guide this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Java » Servlets
Bookmark "Session Listener not getting invoked" Watch "Session Listener not getting invoked" New topic

Session Listener not getting invoked

Krishna Sri Divi

Joined: Feb 20, 2009
Posts: 2
Hi, I'm new to servlets and JSPs. I created a test session listener (source from rose india).
Listener code



I deployed this app in tomcat web server. According to my understanding i should able to see the print statements in listener class either in console or logs when it gets invoked. Please correct me if i'm wrong. I could see only servlet print statements on console but not listener's. Any enlightenment is much helpful.
Krishna sri.
Jeanne Boyarsky
author & internet detective

Joined: May 26, 2003
Posts: 33132

I'm surprised Tomcat doesn't give you and error about bad web.xml. It should be:

You were missing an "e" in listener.

[OCA 8 book] [Blog] [JavaRanch FAQ] [How To Ask Questions The Smart Way] [Book Promos]
Other Certs: SCEA Part 1, Part 2 & 3, Core Spring 3, TOGAF part 1 and part 2
Seetharaman Venkatasamy
Ranch Hand

Joined: Jan 28, 2008
Posts: 5575

Jeanne Boyarsky wrote:You were missing an "e" in listener.

excellent Jeanne
Krishna Sri Divi

Joined: Feb 20, 2009
Posts: 2
Thanks so much Jeanne! Very nice catch. . Surprisingly this error was not visible in logs and application was not running as expected.
William Brogden
Author and all-around good cowpoke

Joined: Mar 22, 2000
Posts: 13037
Are you actually seeing those attributes when the sessionDestroyed method is called?

I have been under the impression that you can't rely on session contents still being there when sessionDestroyed is called.

PS: AHA - I get to answer my own question. Prior to servlet API 2.4 the state was undefined. API 2.3 definitively states that sessionDestroyed is called before the session is invalidated. I think I got bit by this years ago with an early Tomcat version.
I agree. Here's the link:
subject: Session Listener not getting invoked
It's not a secret anymore!