private static void initPropertyMap(ServletContext sc) {

    String fileName = System.getenv("APP_PROPS");
    if (fileName == null) {
      fileName = System.getProperty("app.props");
      if (fileName == null) {
        fileName = "application.properties";
      }
    }
    
    PropertyMap map = new PropertyMap();
    if (sc == null) {
      log.info("initialising without servletContext, setting webContextPath to empty string");
      map.put("webContextPath", "");
      
    } else {
      String contextPath = sc.getContextPath();
      map.put("contextPath", contextPath);
      log.info("initialising with servletContext, contextPath:[{}]", contextPath);
      if ("".equals(contextPath)) {
        contextPath = "root";
      }
      contextPath = contextPath.replace("/", "");
      log.info("setting webContextPath={}", contextPath);
      map.put("webContextPath", contextPath);
    }

    globalMap = PropertyMapLoader.load(map, fileName);
    if (globalMap == null) {
      globalMap = new PropertyMap();
    }
    
    if (globalMap.getBoolean("loadIntoSystemProperties", false)) {
      log.info("loading AppProperties into SystemProperties ...");
      // Load each property into SystemProperties
      Set<Entry<String,String>> entrySet = globalMap.entrySet();
      for (Entry<String, String> entry : entrySet) {
        System.setProperty(entry.getKey(), entry.getValue());
      }
    }
  }