title: Read Properties file in WEB-INF folder java using init
body: <p>I am trying to Read a properties file inside WEB-INF but all I am getting is null. I am completely new to java web development.</p>
  
  <p>My init method:</p>
  
  <pre><code> @Override
      public void init() throws ServletException {
          try {
              String path = "";
              path = "/WEB-INF/" + getServletContext().getInitParameter("monpesapropertiesfile");
              String realPath;
              realPath = getServletContext().getRealPath(path);
              if(realPath != null){
                   InputStream fis = new FileInputStream(realPath);
                   prop.load(fis);
              }
          } catch (Exception asd) {
              System.out.println(asd.getMessage());
          }
      }
      public String getDatabaseUrl() {
          String url = prop.getProperty("database.url");
          return url;
      }
  </code></pre>
  
  <p>My Web.xml:</p>
  
  <pre><code>&lt;context-param&gt;
          &lt;param-name&gt;monpesapropertiesfile&lt;/param-name&gt;
          &lt;param-value&gt;monpesaproperties.properties&lt;/param-value&gt;
      &lt;/context-param&gt;
      &lt;servlet&gt;
          &lt;servlet-name&gt;ReadProperty&lt;/servlet-name&gt;
          &lt;servlet-class&gt;com.monpesa.properties.ReadProperty&lt;/servlet-class&gt;
          &lt;load-on-startup&gt;1&lt;/load-on-startup&gt;
      &lt;/servlet&gt;
  </code></pre>
  
  <p>I know I must be missing something because the String getDataBaseUrl Returns null. Please help.</p>