title: Glassfish 5: specify document base to store the uploaded files on Server's file system
body: <p>I am building a JSF2.2 web application and server is GlassFish V5. I am looking to configure the directly where I could store the files uploaded my the users of the website.</p>
  
  <p>I am using the following code to store the files in the server's (Mac) path of <code>/var/gdf</code> (<code>gdf</code> being the web app's context name).</p>
  
  <p>The code that fails is <code>part.write("/var/gdf/"+getFileName(part));</code> where <code>part</code> is an instance of <code>javax.servlet.http.Part;</code> And the code for <code>getFileName(part)</code> is as follows:-</p>
  
  <pre class="lang-java prettyprint-override"><code>private static String getFileName(Part part){
       String filename=null;
       for (String cd : part.getHeader("content-disposition").split(";")) {
            if (cd.trim().startsWith("filename")){
                 filename=cd.substring(cd.indexOf('=')+1).trim();
            }
       }
       return filename;
  }
  </code></pre>
  
  <p>However, with each reboot of the Glassfish server, I see the following error on the logs:</p>
  
  <blockquote>
    <p>Severe:   java.io.FileNotFoundException:
    /Users///glassfish5/glassfish/domains/domain1/generated/jsp/gdf/var/gdf/2O4A1012.JPG
    (No such file or directory)</p>
  </blockquote>
  
  <p>Any suggestion would be highly appreciated.</p>