监听器:是建立或者修改servlet环境或会话对象时通知的类
配置:
listeners.SessionListener
类:
package listener;
import javax.servlet.http.HttpSessionEvent;
import javax.servlet.http.HttpSessionListener;
public class SessionListener implements HttpSessionListener {
public static int count;
public SessionListener(){
count=0;
}
@Override
public void sessionCreated(HttpSessionEvent arg0) {
// TODO Auto-generated method stub
count++;
}
@Override
public void sessionDestroyed(HttpSessionEvent arg0) {
// TODO Auto-generated method stub
}
}
jsp页面中: 您是第<%=com.wuxiaoxiao.ranran.SessionListener.count%>位访问者
阅读(709) | 评论(0) | 转发(0) |