home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
PC World 1999 November
/
PCWorld_1999-11_cd.bin
/
Komunik
/
Sambar
/
_setup.1
/
ServletList.java
< prev
next >
Wrap
Text File
|
1999-08-28
|
1KB
|
52 lines
package sysadmin;
import java.io.*;
import java.util.*;
import javax.servlet.*;
import javax.servlet.http.*;
public class ServletList 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();
ServletContext context = getServletContext();
String host = req.getServerName();
Enumeration names = context.getServletNames();
while(names.hasMoreElements())
{
String name = (String)names.nextElement();
Servlet servlet = context.getServlet(name);
out.println("Servlet Name: <a href=\"http://" + host +
"/servlet/sysadmin/ServletKiller?s=" + name + "\">" +
name + "</a><br>");
out.println("Servlet Class: " + servlet + "<br>");
out.println("Servlet Info: " + servlet.getServletInfo());
out.println("<hr size=0>");
}
}
public String getServletInfo()
{
return "Lists all currently loaded servlets.";
}
public void destroy()
{
super.destroy();
}
}