Context: listBindings(String name) : Context « javax.naming « Java by API






Context: listBindings(String name)

   
import java.io.IOException;
import java.io.PrintWriter;

import javax.naming.Binding;
import javax.naming.Context;
import javax.naming.InitialContext;
import javax.naming.NamingEnumeration;
import javax.naming.NamingException;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

public class EnvEntry extends HttpServlet {

  public void doGet(HttpServletRequest req, HttpServletResponse res) throws ServletException,
      IOException {
    res.setContentType("text/plain");
    PrintWriter out = res.getWriter();

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

      while (e.hasMore()) {
        Binding binding = (Binding) e.next();
        out.println("Name: " + binding.getName());
        out.println("Type: " + binding.getClassName());
        out.println("Value: " + binding.getObject());
        out.println();
      }
    } catch (NamingException e) {
      e.printStackTrace(out);
    }
  }
}

           
         
    
    
  








Related examples in the same category

1.Context.INITIAL_CONTEXT_FACTORY
2.Context.PROVIDER_URL
3.Context.SECURITY_AUTHENTICATION
4.Context.SECURITY_CREDENTIALS
5.Context.SECURITY_PRINCIPAL
6.Context: addToEnvironment(String propName, Object propVal)
7.Context: close()
8.Context: createSubcontext(String name)
9.Context: destroySubcontext(String name)
10.Context: getNameInNamespace()
11.Context: getNameParser(String name)
12.Context: lookup(String name)
13.Context: rename(String oldName, String newName)
14.Context: unbind(String name)