File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Servlets and the fly likes Servlet Listeners--not working Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Servlets
Bookmark "Servlet Listeners--not working" Watch "Servlet Listeners--not working" New topic

Servlet Listeners--not working

Mike Parker

Joined: Nov 21, 2004
Posts: 18
Hi, I am running j2sdk1.4.x, with Tomcat 4.1.x. I have made a listener, from different tutorials I have found, and it isn't working here is the listener code:

And here is my .jsp code that I want to run this upon:

Lastly, here is my web.xml file for this application:

etc etc etc....

Everytime I run the Sessions.jsp page, I always get the answer of "0" persons have active sessions.

Does anyone see any glaring errors that I might have made?

Much thanks for any help.

Adeel Ansari
Ranch Hand

Joined: Aug 15, 2004
Posts: 2874
check by printing something in your sessionCreated(), and sessionDestroyed() method.

you haven't specified the package where your listener resides. this might be a problem.

i mean you didn't wrote something like following in your listener class e.g.

package com.something;

Sheldon Fernandes
Ranch Hand

Joined: Aug 18, 2004
Posts: 157
Try putting the <listener> element just before the <servlet> element.
For more information about web.xml elements and their order click here.

Sheldon Fernandes
Mike Parker

Joined: Nov 21, 2004
Posts: 18
Hi, thanks for the answers.

I do have the package in the listener class--just didn't paste it to the forum. I put System.out.println in the sessionCreated method, but it didn't do anything.

I do have the listener tag before the servlet in web.xml. Any other ideas?
I agree. Here's the link:
subject: Servlet Listeners--not working
It's not a secret anymore!