统计在线人数

1         ServletContext sc = this.getServletContext();
2         Long personCount = (Long)sc.getAttribute("personCount");
3         if(personCount==null){
4             personCount=(long)0;
5             sc.setAttribute("personCount", personCount);
6             
7         }
8         sc.setAttribute("personCount", (personCount+1));
9         System.out.println("当前在线人数:"+sc.getAttribute("personCount"));    
原文地址:https://www.cnblogs.com/pxffly/p/7465818.html