JSP session 获取id和session持续时间

<%@ page contentType="text/html;charset=utf-8" pageEncoding="utf-8"%>
<html>
    <head>
        <title>
            show session
        </title>
    </head>

    <body>
        <center>
            <h2>获取session</h2>

        <%
            String sessionID= session.getId();
            Long startTime=session.getCreationTime();
            Long endTime=session.getLastAccessedTime();
            Long time =(endTime-startTime)/ 1000;
        %>
        session ID: <%=sessionID%>
        </br>
        停留时间:    <%=time%></center>
        
    </body>
</html>
原文地址:https://www.cnblogs.com/unixshell/p/3176391.html