Environment Properties

The Preparations lesson discussed how to set up a Hashtable object, populate it with some properties, and then use it as a parameter to the InitialContext constructor. Here is an example.

Hashtable env = new Hashtable();
env.put(Context.INITIAL_CONTEXT_FACTORY, "com.sun.jndi.ldap.LdapCtxFactory");
env.put(Context.PROVIDER_URL, "ldap://localhost:389/o=JNDIDocs");
Context ctx = new InitialContext(env);
Almost every example in this book uses a similar pattern. The data in the Hashtable is called environment properties, or simply environment. The use of the Hashtable as shown is but one way to specify environment properties.

This lesson describes in detail what environment properties are, where they come from, and how they are used by the JNDI. It also describes how to update environment properties and how to customize a service provider using properties.