A
AndiArt
Hi,
I developed a monitoring for my web programm, which shows, which users
are online. For that reason, if I log in or log out, an entry is made
into and deleted from the database. But if the session expires, it
should also delete the corresponding entry from the database.
I used a javax.servlet.http.HttpSessionActivationListener but it
doesn't work. I'd like to show you my source code:
the listener:
----------------------------------
package de.hc.listener;
import javax.servlet.http.HttpSessionActivationListener;
import javax.servlet.http.HttpSessionEvent;
public class SessionPassivateListener implements
HttpSessionActivationListener {
@Override
public void sessionDidActivate(HttpSessionEvent arg0) {
}
@Override
public void sessionWillPassivate(HttpSessionEvent evt) {
de.hc.Password pwd =
(de.hc.Password)evt.getSession().getAttribute("pwd");
try {
System.out.println("Hello!");
pwd.LogoutProtokoll();
} catch (Exception e) {
}
}
}
---------------------------
my web.xml:
---------------------------
<listener>
<listener-class>
de.hc.listener.SessionPassivateListener
</listener-class>
</listener>
<session-config>
<session-timeout>1</session-timeout>
</session-config>
I developed a monitoring for my web programm, which shows, which users
are online. For that reason, if I log in or log out, an entry is made
into and deleted from the database. But if the session expires, it
should also delete the corresponding entry from the database.
I used a javax.servlet.http.HttpSessionActivationListener but it
doesn't work. I'd like to show you my source code:
the listener:
----------------------------------
package de.hc.listener;
import javax.servlet.http.HttpSessionActivationListener;
import javax.servlet.http.HttpSessionEvent;
public class SessionPassivateListener implements
HttpSessionActivationListener {
@Override
public void sessionDidActivate(HttpSessionEvent arg0) {
}
@Override
public void sessionWillPassivate(HttpSessionEvent evt) {
de.hc.Password pwd =
(de.hc.Password)evt.getSession().getAttribute("pwd");
try {
System.out.println("Hello!");
pwd.LogoutProtokoll();
} catch (Exception e) {
}
}
}
---------------------------
my web.xml:
---------------------------
<listener>
<listener-class>
de.hc.listener.SessionPassivateListener
</listener-class>
</listener>
<session-config>
<session-timeout>1</session-timeout>
</session-config>