package com.newegg.shopping.util.listener;

import javax.servlet.http.HttpSessionAttributeListener;
import javax.servlet.http.HttpSessionBindingEvent;
import javax.servlet.http.HttpSessionEvent;
import javax.servlet.http.HttpSessionListener; public class LoggedUserCounter implements HttpSessionListener, HttpSessionAttributeListener { private static int count = 0; public void sessionCreated(HttpSessionEvent event) {
System.out.println("------------session created!");
} public void sessionDestroyed(HttpSessionEvent event) {
} public void attributeAdded(HttpSessionBindingEvent event) {
if(event.getName().equals("admin") && ((String)event.getValue()).equals("admin")) {
count ++;
System.out.println("a user logged in ! now total :" + count);
}
} public void attributeRemoved(HttpSessionBindingEvent arg0) { } public void attributeReplaced(HttpSessionBindingEvent arg0) { } }

可折叠代码块package com.newegg.shopping.util.listener;

import javax.servlet.http.HttpSessionAttributeListener;
import javax.servlet.http.HttpSessionBindingEvent;
import javax.servlet.http.HttpSessionEvent;
import javax.servlet.http.HttpSessionListener; public class LoggedUserCounter implements HttpSessionListener, HttpSessionAttributeListener { private static int count = 0; public void sessionCreated(HttpSessionEvent event) {
System.out.println("------------session created!");
} public void sessionDestroyed(HttpSessionEvent event) {
} public void attributeAdded(HttpSessionBindingEvent event) {
if(event.getName().equals("admin") && ((String)event.getValue()).equals("admin")) {
count ++;
System.out.println("a user logged in ! now total :" + count);
}
} public void attributeRemoved(HttpSessionBindingEvent arg0) { } public void attributeReplaced(HttpSessionBindingEvent arg0) { } }

 

windows live Writer test的更多相关文章

  1. Windows Live Writer代码插件整理

    以下code插件命名按照 Windows Live Writer 中显示的插件名 1.Source code plug-in(cnblogs官方推荐) 界面: 效果: /** * Returns th ...

  2. Windows Live Writer 的昨日荣光

    今天这一篇文章,想写一写Windows Live Writer这款博客编辑器(最早的一个版本是2007年发布的).毫不夸张地说,这是为数不多的几款所见即所得的编辑器之一,当然,它的运行速度慢也是一个众 ...

  3. Windows Live Writer测试

    第一次使用Windows Live Writer,一堆问题,不知道是中国强大的局域网防火墙问题还是咋的,弄了半天. 1.C++的测试代码: int _tmain(int argc, _TCHAR* a ...

  4. Windows Live Writer发布测试

    通过Windows Live Writer发布文章测试!!!!

  5. 新语言代码高亮及Windows Live Writer插件开发

    最近在博客园做一些学习笔记.一个是看apple的swift官方书,另外一个是随学校课堂(SICP)学习scheme. 这两种语言都谈不上普及(或者说swift太新).博客园原来的windows liv ...

  6. Windows Live Writer体验

    [安装] 首先下载安装包安装软件,没啥好说的,baidupan有记录: 顺便下载两个工具,备用: a)SourceCodePlugin_version_1.1.zip 将WindowsLiveWrit ...

  7. Windows Live Writer 初次使用

    Windows  Live Writer 博客园文章的一款发布器,这篇文章就是通过其发布的,可以先在word中写好博客内容,直接粘贴到这里发布就OK,之前我都是先在Word中写好一份,然后在blogs ...

  8. 移动windows live writer文章的保存路径

    windows live writer强制安装在C盘,文章也是强制保存在我的文档中.那么我们想办法来改变保存的路径,防止重装系统的时候忘记保存C盘的东西. 网上找到的参考:http://www.dit ...

  9. MetaWeblog博客客户端工具之Windows Live Writer

    吐槽&注意的坑: 刚听说了有这么一个东西,据说Windows Live Writer开源之后就改名为Open Live Writer,我以为Open Live Writer就要比Windows ...

  10. Windows Live Writer技巧

    (此文章同时发表在本人微信公众号"dotNET每日精华文章",欢迎右边二维码来关注.) 题记:今天的内容虽然和开发技术无关,却应该和喜欢写东西的技术人员有关,比如我所有的文章都是用 ...

随机推荐

  1. 我的BluetoothChat示例源码阅读笔记

    BluetoothChat核心类BluetoothChatService,该类用于管理与其他设备的蓝牙连接和设置.该类包含AcceptThread.ConnectedThread.ConnectThr ...

  2. iOS 滑动隐藏导航栏-三种方式

    /** 1隐藏导航栏-简单- */    self.navigationController.hidesBarsOnSwipe = YES; /** 2隐藏导航栏-不随tableView滑动消失效果 ...

  3. 免费开发者证书真机调试App ID失效问题:"Unable to add App ID because the '10' App ID limit in '7' days has been exceeded."解决方案(5月5号)

    免费开发者证书真机调试App ID失效问题:"Unable to add App ID because the '10' App ID limit in '7' days has been ...

  4. iOS中的UI

    • 不管你是学习android开发还是iOS开发• 都建议先学习UI,原因如下:UI是app的根基:⼀一个app应该是先有UI界⾯面,然后在UI的基础上增加实⽤用功能 UI相对简单易学:UI普遍是学 ...

  5. 单例模式-用GCD实现

    用GCD实现单例模式的步骤: 步骤1. 创建头文件 XZSingleton.h,里面代码如下: // .h文件 #define XZSingletonH(name) + (instancetype)s ...

  6. [译] MYSQL索引最佳实践

    近日整理文档时发现多年前的这个文档还是蛮实用的,然后在网络搜索了一下并没有相关的译文,所以决定把它翻译过来,如有不当的地方请多包涵和指正.原文地址:https://www.percona.com/fi ...

  7. 分享php工作中遇到的一些探究和技巧【1】

    一 foreach的引用 $arr = range(,); //[1,2,3] foreach($arr as &$val) { } foreach($arr as $val) { } pri ...

  8. webpack入门和实战(一):webpack配置及技巧

    一.全面理解webpack 1.什么是 webpack? webpack是近期最火的一款模块加载器兼打包工具,它能把各种资源,例如JS(含JSX).coffee.样式(含less/sass).图片等都 ...

  9. 腾讯Tinker初入门总结

  10. php截取字符串函数

    public function sub_string($str, $len, $charset="utf-8") { if( !is_numeric($len) or $len & ...