国产探花免费观看_亚洲丰满少妇自慰呻吟_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://www.survivalescaperooms.com)



發(fā)表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發(fā)表
主站蜘蛛池模板: 崇仁县| 肃宁县| 乐亭县| 石景山区| 潜江市| 辽源市| 梧州市| 金平| 新泰市| 夏河县| 浦江县| 镇平县| 伽师县| 友谊县| 广宗县| 内丘县| 荆州市| 苍山县| 香河县| 虞城县| 翼城县| 邓州市| 会东县| 门头沟区| 奉新县| 中西区| 五常市| 乐安县| 连江县| 湘潭市| 平潭县| 石景山区| 游戏| 扶余县| 普安县| 禄劝| 平湖市| 梁河县| 兰坪| 遵化市| 瑞金市|