国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 學院 > 開發(fā)設計 > 正文

演示Session Listener的使用方法

2019-11-18 16:07:11
字體:
供稿:網(wǎng)友
import java.util.Date;

import javax.servlet.http.Httpsession;
import javax.servlet.http.HttpSessionEvent;
import javax.servlet.http.HttpSessionListener;

public class SessionListen implements HttpSessionListener {

  PRivate int sessionCount;

  public SessionListen() {
    this.sessionCount = 0;
  }

  public void sessionCreated(HttpSessionEvent se) {
    HttpSession session = se.getSession();
    session.setMaxInactiveInterval(60);
    synchronized (this) {
      sessionCount++;
    }
    String id = session.getId();
    Date now = new Date();
    String message = new StringBuffer("New Session created on ").append(
        now.toString()).append("/nID: ").append(id).append("/n")
        .append("There are now ").append("" + sessionCount).append(
            " live sessions in the application.").toString();

    System.out.println(message);
  }

  public void sessionDestroyed(HttpSessionEvent se) {

    HttpSession session = se.getSession();
    String id = session.getId();
    synchronized (this) {
      --sessionCount;
    }
    String message = new StringBuffer("Session destroyed"
        + "/nValue of destroyed session ID is").append("" + id).append(
        "/n").append("There are now ").append("" + sessionCount)
        .append(" live sessions in the application.").toString();
    System.out.println(message);
  }
}

(出處:http://m.survivalescaperooms.com)



發(fā)表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發(fā)表
主站蜘蛛池模板: 泰兴市| 新乡县| 蒲江县| 鄂托克前旗| 九江市| 卢龙县| 台江县| 木兰县| 平顶山市| 彭山县| 凤冈县| 吉安市| 远安县| 祁连县| 天门市| 花莲县| 濮阳市| 昌吉市| 淮滨县| 库尔勒市| 新野县| 永胜县| 石泉县| 安泽县| 尼木县| 上杭县| 泽州县| 高尔夫| 贡嘎县| 长葛市| 嵩明县| 清镇市| 体育| 鄂托克前旗| 贞丰县| 佛学| 新泰市| 正镶白旗| 桃园县| 日土县| 临朐县|