title: How to set environment variables with different values for each subdomain on Tomcat 7?
body: <p>I am trying to use environment Variables to set my Hibernate config database parameters for the same app running on different sub-domains on the same server. </p>
  
  <p>Forexample : </p>
  
  <p>1- www.xxx.com -> dbname=xxx_live</p>
  
  <p>2- dev.xxx.com -> dbname=xxx_dev</p>
  
  <p>And then in my Java app I want to get the environment variable of current subdmoain's and set it as hibernate config parameter. </p>
  
  <p>I understood that I can get environment variables as follows from inside the app:</p>
  
  <pre><code>      Configuration cfg = new Configuration();
        cfg.setProperty("hibernate.connection.url", 
        System.getenv("DATABASE_URL"));
        SessionFactory sessionFactory = cfg.buildSessionFactory();
  </code></pre>
  
  <p>If I can set the same variable with different values for different subdomains then I can use this code to get and set hibernate configuration parameters. </p>
  
  <p>Question is "How can I do it?"</p>
  
  <p>Thanks in advance</p>