1.先 使用MyHttpSessionListener 接口 HttpSessionListener
每次新建一個(gè)session 獲取sessionId 統(tǒng)計(jì)在線人數(shù)
2.MyServletRequestListener 接口 ServletRequestListener
每打開一個(gè)頁面 即創(chuàng)建
通過request獲取ip地址 創(chuàng)建時(shí)間 保存在userList
3.SessionUtil 判斷兩個(gè)sessionId是否相同
4.將userList保存在ServletContext(application)
每次新建一個(gè)session 獲取sessionId 統(tǒng)計(jì)在線人數(shù)
2.MyServletRequestListener 接口 ServletRequestListener
每打開一個(gè)頁面 即創(chuàng)建
通過request獲取ip地址 創(chuàng)建時(shí)間 保存在userList
3.SessionUtil 判斷兩個(gè)sessionId是否相同
4.將userList保存在ServletContext(application)
2017-12-28
使用注解 添加這一句@WebListener ,就不需要在web.xml中進(jìn)行配置
2017-12-12
request.setAttribute();
request.getSession().setAttribute();
request.getServletContext().setAttribute();
這樣就可以獲得。
老師的request.getSession().getServletContext().setAttribute();也行
request.getSession().setAttribute();
request.getServletContext().setAttribute();
這樣就可以獲得。
老師的request.getSession().getServletContext().setAttribute();也行
2017-12-06