public interface HttpSessionListener
extends java.util.EventListener
Implementations of this interface may are notified of changes to the list of active sessions in a web application. To recieve notification events, the implementation class must be configured in the deployment descriptor for the web application.
public class MyServlet extends HttpServlet implements HttpSessionListener
没有试过 我想应该是这样的吧。试试看。