home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
PC World 2000 September
/
PCWorld_2000-09_cd.bin
/
Komunik
/
sambar
/
_setup.1
/
SessionInfo.java
< prev
next >
Wrap
Text File
|
1999-08-28
|
3KB
|
78 lines
package sysadmin;
import java.io.*;
import java.util.*;
import javax.servlet.*;
import javax.servlet.http.*;
public class SessionInfo extends HttpServlet
{
public void init(ServletConfig config)
throws ServletException
{
super.init(config);
}
public void service(HttpServletRequest req, HttpServletResponse res)
throws ServletException, IOException
{
// Only the Sambar System Administrator may run this servlet
String isAdmin = (String)req.getAttribute("isSambarAdmin");
if (isAdmin == null)
return;
res.setContentType("text/html");
PrintWriter out = res.getWriter();
out.println("User Name: " + req.getRemoteUser() + "<br>");
out.println("Authorization Type: " + req.getAuthType() + "<br>");
out.println("<br><br>");
out.println("Here are all the current sessions:<br> ");
HttpSession session = req.getSession(true);
HttpSessionContext context = session.getSessionContext();
Enumeration ids = context.getIds();
out.println("<table border=1 cellpadding=0 cellspacing=0>");
out.println("<tr>");
out.println("<td align=middle><font size=-1><b>Session ID</b></font></font></td>");
out.println("<td align=middle><font size=-1><b>Values</b></font></font></td>");
out.println("<td align=middle><font size=-1><b>New Session</b></font></font></td>");
out.println("<td align=middle><font size=-1><b>Created</b></font></font></td>");
out.println("<td align=middle><font size=-1><b>Last Accessed</b></font></font></td>");
out.println("</tr>");
while (ids.hasMoreElements())
{
out.println("<tr>");
String id = (String)ids.nextElement();
out.println("<td align=middle><font size=-1> "+id +" </font></td>");
HttpSession foreignSession = context.getSession(id);
String sessions[] = foreignSession.getValueNames();
out.print("<td align=middle><font size=-1>");
for(int s = 0; s < sessions.length; s++)
out.print(sessions[s] +", ");
out.println("</font></td>");
if(foreignSession.isNew())
out.println("<td align=middle><font size=-1>Y</font></td>");
else
out.println("<td align=middle><font size=-1>N</font></td>");
out.println("<td align=middle><font size=-1>" +
new Date(foreignSession.getCreationTime())+"</font></td>");
out.println("<td align=middle><font size=-1>" +
new Date(foreignSession.getLastAccessedTime())+"</font></td>");
out.println("</tr>");
}
out.println("</table>");
session.invalidate();
out.flush();
out.close();
}
}