title: Create folder and upload file using servlet
body: <p>I have two web project that use <strong>tomcat</strong>..this is my directory structure..</p>
  
  <pre><code>webapps
  --project1
    --WEB-INF
  --project2
    --WEB-INF
  </code></pre>
  
  <p>I use commons-fileupload..this is part my code in <strong>servlet</strong> in project1</p>
  
  <pre><code>String fileName = item.getName();    
  String root = getServletContext().getRealPath("/");
  File path = new File(root + "/uploads");
  
  if (!path.exists()) {
      path.mkdirs();
  }
  
  File uploadedFile = new File(path + File.separator + fileName);
  item.write(uploadedFile);
  </code></pre>
  
  <p>This will create 'uploads' folder in 'project1' but I want to create 'uploads' folder in 'webapps' because I dont want 'uploads' folder gone when I undeploy 'project1'..</p>
  
  <p>I already try <code>String root = System.getProperty("catalina.base");</code> but not work..</p>
  
  <p>Can anyone help me...thanks in advance</p>