实现浏览器直接的session共享问题
2011-01-26 11:51
155 查看
public class MySessionContext {
private static HashMap mymap = new HashMap();
public static synchronized void AddSession(HttpSession session) {
if (session != null) {
mymap.put(session.getId(), session);
}
}
public static synchronized void DelSession(HttpSession session) {
if (session != null) {
mymap.remove(session.getId());
}
}
public static synchronized HttpSession getSession(String session_id) {
if (session_id == null)
return null;
return (HttpSession) mymap.get(session_id);
}
}
第二步:
public class MySessionListener implements HttpSessionListener {
public void sessionCreated(HttpSessionEvent httpSessionEvent) {
MySessionContext.AddSession(httpSessionEvent.getSession());
}
public void sessionDestroyed(HttpSessionEvent httpSessionEvent) {
HttpSession session = httpSessionEvent.getSession();
MySessionContext.DelSession(session);
}
}
第三步:
<listener>
<listener-class>com.tr.MySessionListener</listener-class>
</listener>
private static HashMap mymap = new HashMap();
public static synchronized void AddSession(HttpSession session) {
if (session != null) {
mymap.put(session.getId(), session);
}
}
public static synchronized void DelSession(HttpSession session) {
if (session != null) {
mymap.remove(session.getId());
}
}
public static synchronized HttpSession getSession(String session_id) {
if (session_id == null)
return null;
return (HttpSession) mymap.get(session_id);
}
}
第二步:
public class MySessionListener implements HttpSessionListener {
public void sessionCreated(HttpSessionEvent httpSessionEvent) {
MySessionContext.AddSession(httpSessionEvent.getSession());
}
public void sessionDestroyed(HttpSessionEvent httpSessionEvent) {
HttpSession session = httpSessionEvent.getSession();
MySessionContext.DelSession(session);
}
}
第三步:
<listener>
<listener-class>com.tr.MySessionListener</listener-class>
</listener>
相关文章推荐
- session+application+cookie 实现单态登陆,且解决浏览器意外关闭的问题(转自http://blog.csdn.net/u010723709/article/details/4)
- 解决同一PC同一浏览器session共享问题
- 使用nginx搭建集群tomcat8,redis实现session共享,文件共享问题
- 关于多标签浏览器中session共享引发的问题
- zk+redis+tomcat 实现session共享遇到问题
- 关于多标签浏览器中session共享引发的问题
- 使用Tomcat+Redis来实现集群部署中的Session共享问题
- 利用session+application+cookie 实现单态登陆,且解决浏览器意外关闭的问题
- spring boot--整合spring session实现session共享以及cookie丢失问题解决
- 使用nginx搭建集群tomcat8,redis实现session共享,文件共享问题
- 解决同一浏览器登录多个账户session共享问题
- memcached实现session共享问题总结
- 使用Tomcat+Redis来实现集群部署中的Session共享问题
- tomcat-redis-session-manager实现负载均衡session共享问题
- redis+cookies实现session机制(解决 手机浏览器不自动回传cookies导致session不可用问题)
- 分布式系统登录功能拦截器的实现以及cookie的共享问题(利用cookie实现session在分布式系统的共享)
- jsp中验证码的实现,以及ajax实现的正确的验证,解决了session不同步的问题。(我这里已测试过,可以直接用)
- Servlet课程0425(六) 不经过验证直接跳转---session实现不同页面之间共享数据
- 使用nginx搭建集群tomcat8,redis实现session共享,文件共享问题
- SpringCloud实现Redis在各个微服务的Session共享问题