zoukankan      html  css  js  c++  java
  • session

    浏览器打开显示

    listener

    package cn.swpu.pang;

    import javax.servlet.ServletContext;
    import javax.servlet.annotation.WebListener;
    import javax.servlet.http.HttpSessionEvent;
    import javax.servlet.http.HttpSessionListener;

    @WebListener
    public class OnlineUserCountListener implements HttpSessionListener {
    public static int num=0;
    public OnlineUserCountListener() {


    }

    public void sessionCreated(HttpSessionEvent se) {
    System.out.println("session创建");

    num++;
    }

    public void sessionDestroyed(HttpSessionEvent se) {
    System.out.println("session销毁");
    num--;
    }

    }

    servlet

    package cn.swpu.pang;

    import java.io.IOException;
    import javax.servlet.ServletException;
    import javax.servlet.annotation.WebServlet;
    import javax.servlet.http.HttpServlet;
    import javax.servlet.http.HttpServletRequest;
    import javax.servlet.http.HttpServletResponse;

    /**
    * Servlet implementation class IndexServlet
    */
    @WebServlet("/IndexServlet")
    public class IndexServlet extends HttpServlet {
    private static final long serialVersionUID = 1L;

    public IndexServlet() {
    super();
    }

    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {

    request.getSession(true);
    request.getRequestDispatcher("/MyFisrtPage.jsp").forward(request, response);
    }


    }

  • 相关阅读:
    oracle问题之死锁 (一)
    linux下oracle调试小知识
    Oracle实例名,服务名等概念区别与联系
    oracle 数据库、实例、服务名、SID
    Linux下启动/关闭Oracle
    Oracle监听器
    Oracle数据库、实例、用户、表空间、表之间的关系
    在Centos7上安装Oracle
    理财入门书籍
    [C/C++] VS 2015 C++ 插件
  • 原文地址:https://www.cnblogs.com/hechunhang/p/10707021.html
Copyright © 2011-2022 走看看