Listener_OnlineCount.java
package com.wzucxd.listener; import javax.servlet.ServletContext; import javax.servlet.http.HttpSession; import javax.servlet.http.HttpSessionEvent; import javax.servlet.http.HttpSessionListener; import com.wzucxd.count.CountNum; public class Listener_OnlineCount implements HttpSessionListener { public void sessionCreated(HttpSessionEvent se) { HttpSession session = se.getSession(); ServletContext application = session.getServletContext(); if (session.isNew()) { CountNum.addNum(); application.setAttribute("num", CountNum.getNum()); } } public void sessionDestroyed(HttpSessionEvent se) { HttpSession session = se.getSession(); ServletContext application = session.getServletContext(); if (CountNum.getNum() > 0) { CountNum.minNum(); application.setAttribute("num", CountNum.getNum()); } } }
CountNum.java
package com.wzucxd.count; public class CountNum { private static int i=0; public static int getNum() { return i; } public static void addNum() { i++; } public static void minNum() { i--; } }
index.jsp
<%@ page language="java" import="java.util.*" pageEncoding="ISO-8859-1"%> <%@taglib prefix="c" uri="/WEB-INF/tld/c-rt.tld"%> <%@page import="com.wzucxd.count.CountNum" %> <% String path = request.getContextPath(); String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/"; %> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <html> <head> <base href="<%=basePath%>"> <title>My JSP 'index.jsp' starting page</title> <meta http-equiv="pragma" content="no-cache"> <meta http-equiv="cache-control" content="no-cache"> <meta http-equiv="expires" content="0"> <meta http-equiv="keywords" content="keyword1,keyword2,keyword3"> <meta http-equiv="description" content="This is my page"> <!-- <link rel="stylesheet" type="text/css" href="styles.css" mce_href="styles.css"> --> </head> <body> <c:out value="${applicationScope.num}"></c:out><br><br></body> </html>
您还没有登录,请您登录后再发表评论
使用SessionListener+持久化Session+Springmvc拦截器实现单点登录
这个资源是针对session容器的,在具有多个session的session容器里需要进行注册,所以就有了这个代码。不过写的还是很粗糙的。
jsp中唯一登录,使用session控制.
监控器需要的jar,需在web.xml中配置 <filter-name>monitoring ... <listener-class>net.bull.javamelody.SessionListener</listener-class> 通过web地址:http:xxxx/项目名/monitoring 可以进入到监控页面
javax.media.rtp.event ...通知SessionListener的数据包/ RTCP协议的数据包已经开始停止后抵达抵达。如果在一个活跃的发件人,这涉及到国家的数据包的ReceiveStream 。在被动的情况下接收器,在ReceiveStream将是无效
<listener-class>net.bull.javamelody.SessionListener</listener-class> 2、需监控的web工程引入依赖jar包 jira-javamelody.jar jrobin-1.5.9.1.jar 3、如果您的web项目有SpringSecurity,修改Spring...
- SessionListener: contextInitialized() - Starting Coyote HTTP/1.1 on http-8080 - JK: ajp13 listening on /0.0.0.0:8009 - Jk running ID=0 time=0/32 config=null - Find registry server-registry.xml at ...
{"time":"2017-09-06 10:24:48,649","logtype":"INFO","loginfo":"org.apache.catalina.core.ContainerBase.[Catalina].[bms-res.hzfh.com].[/examples]:SessionListener: contextInitialized()"} {"time":"2017-09-...
相关推荐
使用SessionListener+持久化Session+Springmvc拦截器实现单点登录
这个资源是针对session容器的,在具有多个session的session容器里需要进行注册,所以就有了这个代码。不过写的还是很粗糙的。
jsp中唯一登录,使用session控制.
监控器需要的jar,需在web.xml中配置 <filter-name>monitoring ... <listener-class>net.bull.javamelody.SessionListener</listener-class> 通过web地址:http:xxxx/项目名/monitoring 可以进入到监控页面
javax.media.rtp.event ...通知SessionListener的数据包/ RTCP协议的数据包已经开始停止后抵达抵达。如果在一个活跃的发件人,这涉及到国家的数据包的ReceiveStream 。在被动的情况下接收器,在ReceiveStream将是无效
<listener-class>net.bull.javamelody.SessionListener</listener-class> 2、需监控的web工程引入依赖jar包 jira-javamelody.jar jrobin-1.5.9.1.jar 3、如果您的web项目有SpringSecurity,修改Spring...
- SessionListener: contextInitialized() - Starting Coyote HTTP/1.1 on http-8080 - JK: ajp13 listening on /0.0.0.0:8009 - Jk running ID=0 time=0/32 config=null - Find registry server-registry.xml at ...
{"time":"2017-09-06 10:24:48,649","logtype":"INFO","loginfo":"org.apache.catalina.core.ContainerBase.[Catalina].[bms-res.hzfh.com].[/examples]:SessionListener: contextInitialized()"} {"time":"2017-09-...