((HttpServletRequest)request).getRequestURL()
解决方案 »
- JFreeChart怎么改变相同类型柱子的颜色
- 一个jsp里include另一个jsp,为什么tr会出现"style="display: none; "??看不到列表??
- [Microsoft][ODBC 驱动程序 管理器] 未发现数据源名称并且未
- hubernate saveOrUpdate()方法问题
- JAVA推技术
- struts 超连接的问题
- !!初来贵版,向各位求助!!
- jspSmartUpload到底怎么用啊?
- 哪位大哥有论坛的源代码?
- 如何根据参数来控制 herf是否可用
- 高手请进:include路径问题
- 帮我看看这个oracle的sql语句有什么问题??。。。。在线等。。。。。。。。。
import javax.servlet.http.*;public class CountListener extends HttpServlet implements HttpSessionListener, HttpSessionAttributeListener {
public static int count = Config.getInstance().getCountValue();
private static int sessionCounter=0;
private static int attributeCounter=0;
public CountListener() {
}
public synchronized void sessionCreated(HttpSessionEvent se) {
count++;
sessionCounter++;
try{
Config.getInstance().saveCountValue(count);
}
catch(Exception e){
System.out.println(e);
}
}
在这个方法里取的你要当时的页面;
public synchronized void sessionDestroyed(HttpSessionEvent se) {
sessionCounter--;
}
public void attributeAdded(HttpSessionBindingEvent se) {
attributeCounter++;
}
public void attributeRemoved(HttpSessionBindingEvent se) {
attributeCounter--;
} public void attributeReplaced(HttpSessionBindingEvent se) {
//System.out.println(se.getName()+":is replaced");
}
public synchronized static int getSessionCount(){
//System.out.println(sessionCounter);
return sessionCounter;
}
public synchronized static int getCount() {
return count;
}
}
<!DOCTYPE web-app PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN" "http://java.sun.com/dtd/web-app_2_3.dtd">
<web-app>
<display-name>WebModule1</display-name>
<listener>
<listener-class>jsq.CountListener</listener-class>
</listener>
</web-app>
配置个监听的xml