tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Burkeman" <burke...@mediaone.net>
Subject RE: getServletNames()?
Date Sun, 01 Apr 2001 16:13:16 GMT
I dont see how this even compiled without importing java.util.*.
  -----Original Message-----
  From: George Kakarontzas [mailto:gkakar@inf.uth.gr]
  Sent: Sunday, April 01, 2001 1:58 AM
  To: tomcat-user@jakarta.apache.org
  Subject: getServletNames()?


  Hi all.
  I have been trying to make this run:
  ====================================
  import javax.servlet.http.*;

  public class Loaded extends HttpServlet {

    public void doGet(HttpServletRequest req, HttpServletResponse res)
                                 throws ServletException, IOException {
      res.setContentType("text/plain");
      PrintWriter out = res.getWriter();
      ServletContext context = getServletContext();
      Enumeration names = context.getServletNames();
      while (names.hasMoreElements()) {
        String name = (String)names.nextElement();
        Servlet servlet = context.getServlet(name);
        out.println("Servlet name: " + name);
        out.println("Servlet class: " + servlet.getClass().getName());
        out.println("Servlet info: " + servlet.getServletInfo());
        out.println();
      }
    }
  }
  ========================================
  However the Enumeration returned by context.getServletNames() is empty!
  It is supposed to return the serlvets loaded (including Loaded itself).
  I know that this method has been deprecated in jdk1.3, which I'm using,
but it should work anyway.
  Any suggestions?
  Thanks
  -George



Mime
View raw message