title: Upload file in web application to project root folder
body: <p>I am currently working on a web application. In some part of this application I want to upload files to a certain directory. Initially, when I wrote my test cases this worked perfectly:</p>
  
  <pre><code>final static String IMAGE_RESOURCE_PATH = "res/images";
  
  ...
  
  File directory = new File(IMAGE_RESOURCE_PATH + "/" + productId);
  
  if(!directory.exists()) {
      directory.mkdirs();
  }
  </code></pre>
  
  <p>This creates the directory wherein the file will be uploaded. The resulting path will be:</p>
  
  <p>[project root folder]/res/images/[productId]</p>
  
  <p>Since deploying the application to a server (Tomcat 7), the directory gets created in the root of the IDE I'm using, which is a bit confusing to me.</p>
  
  <p>eg: C:\Eclipse86\res\images</p>
  
  <p>Any idea how I can revert back to the project path with just plain Java without using some hacked technique or hard-coding the path?</p>