一、简单了解
1、服务器会给每个用户(浏览器)创建一个 session 对象
2、一个 session 会独占一个浏览器,只要浏览器没有关闭,session会一直存在
3、用户登录之后,整个网站都可以访问
二、应用
1、创建 session 请求处理
protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
//解决乱码问题
req.setCharacterEncoding("GBK");
resp.setCharacterEncoding("GBK");
resp.setContentType("text/html,charset=GBK");
//得到session
HttpSession session = req.getSession(