To access the properties from your Java/JSP code, use the following syntax:

// Get a handle to the JNDI environment naming contextContext env = (Context)new InitialContext().lookup("java:comp/env");// Get a single valueString webmasterEmail = (String)env.lookup("webmasterEmail");

As with all JNDI names, the <env-entry-name> can be a path instead of a single name. For example:

An example of where you might want to use both types, is if you have multiple data sources defined in context.xml, for example, a local datasource called jdbc/datalocal, a deployment datasource called jdbc/datalive, and a staging datasource called jdbc/datastaging. Your web.xml file can then contain an <env-entry> environment variable, which points to the JNDI URL of the active datasource. Changing between the different datasources is then as simple as changing the environment variable in web.xml.