HttpSession接口中方法
getId()
getCreationTime()
getLastAccessedTime()
setMaxInactiveInterval()
getMaxInactiveInterval()
isNew():如果客户端请求消息中返回了一个与Servlet程序当前获得的HttpSession对象的会话标识号相同,则认为这个HttpSession对象不是新建的
invalidate()
getServletContext()
setAttribute()
getAttribute()
removeAttribute()
getAttributeNames()
login.jsp
<%-- Created by IntelliJ IDEA. User: dell Date: 2019/7/10 Time: 15:52 To change this template use File | Settings | File Templates.--%><%@ page contentType="text/html;charset=UTF-8" language="java" %>Title SessionID:<%= session.getId()%> IsNew:<%= session.isNew()%> MaxInactive:<%=session.getMaxInactiveInterval()%> CreateTime:<%= session.getCreationTime()%> LastAssessTime:<%= session.getLastAccessedTime()%><% Object username = session.getAttribute("username"); if (username ==null){ username =""; }%>
hello.jsp
<%-- Created by IntelliJ IDEA. User: dell Date: 2019/7/10 Time: 15:56 To change this template use File | Settings | File Templates.--%><%@ page contentType="text/html;charset=UTF-8" language="java" %>Title SessionID:<%= session.getId()%>IsNew:<%= session.isNew()%>MaxInactive:<%=session.getMaxInactiveInterval()%>CreateTime:<%= session.getCreationTime()%>LastAssessTime:<%= session.getLastAccessedTime()%>Hello:<%= request.getParameter("username")%><% session.setAttribute("username",request.getParameter("username"));%>重新登录注销
logout.jsp
<%-- Created by IntelliJ IDEA. User: dell Date: 2019/7/10 Time: 16:07 To change this template use File | Settings | File Templates.--%><%@ page contentType="text/html;charset=UTF-8" language="java" %>Title SessionID:<%= session.getId()%>IsNew:<%= session.isNew()%>MaxInactive:<%=session.getMaxInactiveInterval()%>CreateTime:<%= session.getCreationTime()%>LastAssessTime:<%= session.getLastAccessedTime()%>BYE:<%= session.getAttribute("username")%>重新登录<% session.invalidate();%>