FileDocCategorySizeDatePackage
EnvEntrySnoop.javaAPI DocExample970Thu Apr 05 20:21:10 BST 2001None

EnvEntrySnoop

public class EnvEntrySnoop extends HttpServlet

Fields Summary
Constructors Summary
Methods Summary
public voiddoGet(javax.servlet.http.HttpServletRequest req, javax.servlet.http.HttpServletResponse res)

    res.setContentType("text/plain");
    PrintWriter out = res.getWriter();

    try {
      Context initCtx = new InitialContext();
      NamingEnumeration enum = initCtx.listBindings("java:comp/env");

      // We're using JDK 1.2 methods; that's OK since J2EE requires JDK 1.2
      while (enum.hasMore()) {
        Binding binding = (Binding) enum.next();
        out.println("Name: " + binding.getName());
        out.println("Type: " + binding.getClassName());
        out.println("Value: " + binding.getObject());
        out.println();
      }
    }
    catch (NamingException e) {
      e.printStackTrace(out);
    }