java:comp/env is a node in the JNDI tree where you can find properties for the current Java EE component (web application or EJB).
Context envContext = (Context)initContext.lookup("java:comp/env");
allows you to define a variable that points directly to this node. It allows you to do
SomeBean s = (SomeBean) envContext.lookup("ejb/someBean"); DataSource ds = (DataSource) envContext.lookup("jdbc/dataSource");
but not
SomeBean s = (SomeBean) initContext.lookup("java:comp/env/ejb/someBean"); DataSource ds = (DataSource) initContext.lookup("java:comp/env/jdbc/dataSource");
Relative paths instead of absolute paths. This is what it was used for.
JB Nizet Jul 24 2018-12-12T00: 00Z
source share