Simple things, such as String, can be declared as environment entries in web.xmland received through JNDI. The following is an example with env-entrythe name "imagePath".
<env-entry>
<env-entry-name>imagePath</env-entry-name>
<env-entry-value>/somepath_on_production_server/images</env-entry-value>
<env-entry-type>java.lang.String</env-entry-type>
</env-entry>
To access the properties of your Java code, do a JNDI search:
Context env = (Context)new InitialContext().lookup("java:comp/env");
String imagePath = (String)env.lookup("imagePath");
This is usually done in the old style ServiceLocator, where you must cache the value for this key.
- .
maven ( web.xml).