Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>See this <a href="https://stackoverflow.com/questions/883858/what-is-the-best-practice-for-reading-property-files-in-j2ee">question</a> for reading properties file outside of the WAR file.</p> <p>See this <a href="https://stackoverflow.com/questions/490580/how-to-move-the-environment-details-outside-the-ear">question</a> for reading variable values from JNDI. I believe that this is the best solution. You can read a String variable with this code:</p> <pre><code>Context initialContext = new InitialContext(); String myvar = (String) initialContext.lookup("java:comp/env/myvar"); </code></pre> <p>The above code will work on all containers. In Tomcat you declare the following in conf/server.xml:</p> <pre class="lang-xml prettyprint-override"><code>&lt;GlobalNamingResources ...&gt; &lt;Environment name="myvar" value="..." type="java.lang.String" override="false"/&gt; &lt;/GlobalNamingResources&gt; </code></pre> <p>The above will create a global resource. It is also possible to define a resource in the context of application. In most containers the JNDI resources are available through a MBeans Management Console. Some of them offer a graphical interface to edit them. At most an application restart is needed, when a change is made.</p> <p>How JNDI resources are defined and edited is container specific. It is the job of the configurator/administrator to apply the appropriate settings.</p> <p>These are the benefits offered by JNDI:</p> <ul> <li>You can define default values of the parameters in the WAR/EAR file.</li> <li>Parameters are easily configurable at the container.</li> <li>You don't need to restart the container when you modify the value of a parameter.</li> </ul>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload