⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 forumonlinecount.java

📁 struts+hibernate BBS mysql数据库 功能基本齐全
💻 JAVA
字号:
package com.elan.forum.listener;

import javax.servlet.http.HttpSessionEvent;
import javax.servlet.http.HttpSessionListener;

public class ForumOnlineCount implements HttpSessionListener {
	private static int count = 0;
	private static int high = 0;
	public synchronized void sessionCreated(HttpSessionEvent hse) {
		hse.getSession().getServletContext().setAttribute("FourmOnline", ++count);
		if(count > high ) {
			high = count;
		}
		System.out.println("有用户访问");
	}
	public synchronized void sessionDestroyed(HttpSessionEvent hse) {
		if(count > 0) {
			count--;
		}
		hse.getSession().getServletContext().setAttribute("FourmOnline", count);
		System.out.println("有用户退出");
	}
	
	public static int  getHigh() {
		return high;
	}
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -