Skip Headers

Oracle® Containers for J2EE Enterprise JavaBeans Developer's Guide 10g Release 3 (10.1.3) B14428-01 |
| Home | Solution Area | Contents | Index

Previous | Next |

# Looking Up an EJB 2.1 Enviornment Variable

Using EJB 2.1, you can look up an environment variable using the `InitialContext` (see "Using Initial Context").

For more information on configuring enviornment variables, see "Configuring an Environment Reference to an Environment Variable".

## Using Initial Context

Example 19-34 shows how you look up these environment variables within the bean's code using the `InitialContext`.

Example 19-44 Looking Up Environment Variables

    InitialContext ic = new InitialContext();
    Integer min = (Integer) ic.lookup("java:comp/env/minBalance");
    Integer max = (Integer) ic.lookup("java:comp/env/maxCreditBalance"));

Notice that to retrieve the values of the environment variables, you prefix each environment element with "`java:comp/env/`", which is the location that the container stored the environment variable.

For more information, see "Configuring the Initial Context Factory".