关于sessionListener
//问题
谢谢您,可是用session怎么能将客户端的正在浏览的url不断发送到服务器端呢?难道要在客户端做个什么东西,在嵌个浏览器?please give me a hint,thx!
//回答,用sessionListener[Session监听器来实现]
//下边是一个监器的源码,实现了在线人数,依此原理,你能做你想要做的
package core;
/**
* Title: core
* Description:
* Copyright: Copyright (c) 2001
* Company: ****
* @author 罗亭
* @version 1.0
*/
import javax.servlet.*;
import javax.servlet.http.*;
public final class CounterListener implements HttpSessionListener {
private int count = 10;
private ServletContext context = null;
public synchronized void sessionCreated(HttpSessionEvent se) {
count ;
log("sessionCreated('" se.getSession().getId() "'LuoTing's Log)" " count=" count);
se.getSession().setAttribute("count",new Integer(count));
}
public synchronized void sessionDestroyed(HttpSessionEvent se) {
count--;
se.getSession().setAttribute("count",new Integer(count));
}
public int getCount() {
return this.count;
}
public void addCount(){
count ;
}
private void log(String message) {
if (context != null)
您可能感兴趣的文章:
关于sessionListener
迅雷影音如何设置定时关机?
关于html5 player 相关用法总结
B站关闭弹幕开启或关闭教程
关于鼠标动画的详细介绍
Google排名内部优化攻略
关于关键字竞争者的看法
SQL SERVER中查找某关键词位于哪些存储过程或函数中
CSS中未知高度水平垂直居中实例
有关php中++i 与 i++ 的用法