我想不用通过实现httpsessionlistener纪录Session就能遍历当前服务器所有的session,我在网上找了很久没找到,有一段代码说是列出jsp中的所有session,不过根本没有作用:
以下是引用片段:
<%@ page contentType="text/html; charset=gb2312" language="java" %>
<%@ page import="java.util.*"%>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>无标题文档</title>
</head>
<body>
<%
Enumeration e=session.getAttributeNames();
String temp;
for (;e.hasMoreElements();){
temp=(String)e.nextElement();
out.print(temp+"="+(String)session.getAttribute(temp)+"<br>");
}
%>
</body>
</html> 试运行了一下,浏览器没有显示任何东西。