title: Set specified system property for web application
body: <p>I have an JavaEE application which needs some certain system properties configured during the runtime.</p>
  
  <p>During the development phase, we set the properties in the <code>.pom.xml</code> to make it work:</p>
  
  <pre><code>        &lt;plugin&gt;
              &lt;groupId&gt;org.apache.tomcat.maven&lt;/groupId&gt;
              &lt;artifactId&gt;tomcat7-maven-plugin&lt;/artifactId&gt;
              &lt;version&gt;2.2&lt;/version&gt;
              &lt;configuration&gt;
                  &lt;systemProperties&gt;
                  &lt;xxx&gt;true&lt;/xxx&gt;
                  &lt;/systemProperties&gt;
              &lt;/configuration&gt;
          &lt;/plugin&gt;
  </code></pre>
  
  <p>However I wonder how about if we deploy the application in the production environment?</p>
  
  <p>I have though of set the property during the initialization of the servlet, but it seems that I can not modify the system property once the jvm is runing(from <a href="https://stackoverflow.com/a/13604764/306719">this post</a>):</p>
  
  <blockquote>
    <p>The JVM memory parameters for a Hotspot Java implementation can only
    be set via the command line options when the JVM is launched /
    started. Setting them in the system properties either before or after
    the JVM is launched will have no effect.</p>
  </blockquote>
  
  <p>And I have tried to set the properties in the <code>web.xml</code> (<a href="https://stackoverflow.com/a/376827/306719">here</a>):</p>
  
  <pre><code>&lt;env-entry&gt;
      &lt;env-entry-name&gt;xx&lt;/env-entry-name&gt;
      &lt;env-entry-type&gt;java.lang.String&lt;/env-entry-type&gt;
      &lt;env-entry-value&gt;xx&lt;/env-entry-value&gt;
  &lt;/env-entry&gt;
  </code></pre>
  
  <p>But it seems like it does not take affect.</p>
  
  <p>Then I wonder how to solve it?</p>
  
  <p>BTW, in the production environment we may run more than one application under a shared tomcat, so we prefer to set the properties under the application context only.</p>