title: upload file in JSP - how to change a default path for the uploaded file
body: <p>I have two jps pages to handle an upload of the single file. 
  Here is a code for selecting a file:</p>
  
  <pre><code> org.apache.commons.io.FilenameUtils, java.util.*, 
   java.io.File, java.lang.Exception" %&gt;
  ...
   &lt;form name="uploadFile" method="POST" action="processUpload.jsp"     
   enctype="multipart/form-data"&gt;
       &lt;input type="file" name="myfile"&gt;&lt;br /&gt;
       &lt;input type="submit" value="Submit" /&gt;
   &lt;/form&gt;
   ....
  </code></pre>
  
  <p>//--------handle uploaded file---------------------</p>
  
  <pre><code>&lt;%@ page contentType="text/html;charset=windows-1252"%&gt;
  &lt;%@ page import="org.apache.commons.fileupload.DiskFileUpload"%&gt;
  &lt;%@ page import="org.apache.commons.fileupload.FileItem"%&gt;
  &lt;%@ page import="java.util.List"%&gt;
  &lt;%@ page import="java.util.Iterator"%&gt;
  &lt;%@ page import="java.io.File"%&gt;
  
  
  &lt;%
      System.out.println("Content Type ="+request.getContentType());
      System.out.println("Cookies" + request.getCookies());
  
      DiskFileUpload fu = new DiskFileUpload();
      // If file size exceeds, a FileUploadException will be thrown
      fu.setSizeMax(1000000);
  
      List fileItems = fu.parseRequest(request);
      Iterator itr = fileItems.iterator();
  
      while(itr.hasNext()) {
        FileItem fi = (FileItem)itr.next();
  
        //Check if not form field so as to only handle the file inputs
        //else condition handles the submit button input
        if(!fi.isFormField()) {
          System.out.println("\nNAME: "+fi.getName());
          System.out.println("SIZE: "+fi.getSize());
          //System.out.println(fi.getOutputStream().toString());
          File fNew= new File(application.getRealPath("/"), fi.getName());
  
          System.out.println(fNew.getAbsolutePath());
          fi.write(fNew);
        }
        else {
          System.out.println("Field ="+fi.getFieldName());
        }
      }
   %&gt;
  </code></pre>
  
  <p>This code put a file into my build\web folder. 
  How to set a path to a different directory on the server (assuming the write permissions are set) ?
  Thanks,   </p>