home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
PC World 2001 August
/
PCWorld_2001-08_cd.bin
/
Komunikace
/
sambar
/
_setup.1
/
SessionKiller.java
< prev
next >
Wrap
Text File
|
1999-08-28
|
2KB
|
70 lines
package sysadmin;
import java.io.*;
import java.util.*;
import javax.servlet.*;
import javax.servlet.http.*;
public class SessionKiller 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>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("<td align=middle><font size=-1><b>Killed?</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);
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>");
foreignSession.invalidate();
out.println("<td align=middle><font size=-1>Y</font></td>");
out.println("</tr>");
}
out.println("</table>");
session.invalidate();
out.flush();
out.close();
}
}