HttpSession

HttpSession session=request.getSession();
session.setAttribute("online",user); //当前的登录用户名
session.setAttribute("quanxian",flag); //当前用户的权限

response.sendRedirect("mainindex2.jsp?name="+user+""); //用户的跳转

response.sendRedirect("error.jsp");

原文地址:https://www.cnblogs.com/cb168/p/4654075.html