监听器分为
ServletContextListener
HttpSessionListener
ServletRequestListener(了解)
作用: 能够针对创建和销毁定义不同的行为
ServletContextListener‘
HttpSessionListener
一定要在监听器的类上加上 WebListener ,否则该监听器不会被启动
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<head>
<%@taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<meta charset="UTF-8">
<title>Insert title here</title>
</head>
<body>
<h1>当前人数:${onLineCount }</h1>
<h3><a href="exit.do">退出</a></h3>
<h3><a href="admin_a.jsp">管理员A</a></h3>
<h3><a href="admin_b.jsp">管理员B</a></h3>
<h3><a href="tourists.jsp">游客界面</a></h3>
<c:if test="${uname==null}">
<form action="login.do">
用户名:<input type="text"name="uname">
密码:<input type="password" name="upwd">
<button>提交</button>
</form>
</c:if>
<c:if test='${uname==""}'>
<h3>欢迎登陆</h3>
</c:if>
</body>
</html>
过滤器 Filter 精准匹配 /a.jsp 扩展名匹配 *.jsp 路径匹配 /manager/* 匹配所有 /*