title: Using a jsp as a server-side script for uploading a file to an specific folder
body: <p>as the title implies I'm trying to upload a file to a local server and for that purpose I'm using a JSP and uploadify (flash-based jquery uploader). 
  I have already succeeded on uploading a file using glassfish server 3.1 and this as my HTML code:</p>
  
  <pre><code>&lt;/head&gt;
  &lt;body&gt;
      &lt;table&gt;
          &lt;tr&gt;
              &lt;td&gt;
                  &lt;input id="file_upload" name="file_upload" type="file" /&gt;
                  &lt;script type="text/javascript"&gt;
                      $('#file_upload').uploadify({
                          'uploader'    : 'uploadify/uploadify.swf',
                          'script'      : 'UploadFile/uploadFile.jsp',
                          'cancelImg'   : 'uploadify/cancel.png',
                          'multi'       : true,
                          'auto'        : false,
                          'onComplete'  : function(fileObj) 
                          {
                              alert (fileObj.filePath); //The path on the server to the uploaded file
                          }
                      });
                  &lt;/script&gt;
  
              &lt;/td&gt;
              &lt;td&gt;
                  &lt;a href="javascript:$('#file_upload').uploadifyUpload($('.uploadifyQueueItem').last().attr('id').replace('file_upload',''));"&gt;Upload Last File&lt;/a&gt;
              &lt;/td&gt;
          &lt;/tr&gt;
      &lt;/table&gt;
  &lt;/body&gt;
  </code></pre>
  
  <p>And this as my server-side script:</p>
  
  <pre><code>&lt;%@ page import="java.io.*" %&gt;
  &lt;%
  String contentType = request.getContentType();
  if ((contentType != null) &amp;&amp; (contentType.indexOf("multipart/form-data") &gt;= 0)) {
      DataInputStream in = new DataInputStream(request.getInputStream());
  
      int formDataLength = request.getContentLength();
      byte dataBytes[] = new byte[formDataLength];
      int byteRead = 0;
      int totalBytesRead = 0;
  
      while (totalBytesRead &lt; formDataLength) {
          byteRead = in.read(dataBytes, totalBytesRead, formDataLength);
          totalBytesRead += byteRead;
      }
      String file = new String(dataBytes);
  
      String saveFile = file.substring(file.indexOf("filename=\"") + 10);
      saveFile = saveFile.substring(0, saveFile.indexOf("\n"));
      saveFile = saveFile.substring(saveFile.lastIndexOf("\\") + 1, saveFile.indexOf("\""));
      int lastIndex = contentType.lastIndexOf("=");
      String boundary = contentType.substring(lastIndex + 1,contentType.length());
      int pos;
  
      pos = file.indexOf("filename=\"");
      pos = file.indexOf("\n", pos) + 1;
      pos = file.indexOf("\n", pos) + 1;
      pos = file.indexOf("\n", pos) + 1;
      int boundaryLocation = file.indexOf(boundary, pos) - 4;
      int startPos = ((file.substring(0, pos)).getBytes()).length;
      int endPos = ((file.substring(0, boundaryLocation)).getBytes()).length;
  
      FileOutputStream fileOut = new FileOutputStream(saveFile);
      fileOut.write(dataBytes, startPos, (endPos - startPos));
      fileOut.flush();
      fileOut.close();
  %&gt;
  
  &lt;table&gt;
      &lt;tr&gt;
          &lt;td&gt;
              &lt;b&gt;File uploaded:&lt;/b&gt;
              &lt;% out.println(saveFile);%&gt;
          &lt;/td&gt;
      &lt;/tr&gt;
  &lt;/table&gt; 
  
   &lt;%} else {
      out.println(contentType.indexOf("multipart/form-data")); 
      out.println(request.getContentType()); 
  %&gt;
          &lt;br/&gt; error &lt;% } %&gt;
  </code></pre>
  
  <p>So my question is, is it possible to change the default folder to upload things to?
  e.g: My default folder right now is C:\Users\USERNAME.netbeans\7.0\config\GF3\domain1 is it possible to change it to C:\Users\USERNAME\Desktop ?</p>
  
  <p>If I was not clear enough with the question feel free to say it, any help is greatly appreciated, thanks.</p>