I am uploading a file. I want to get the file and save to my local system.To do this i am using spring surf webscripts in java. Can any one tell me how i can get my file .
This is my ftl file :
<form name="frmUpload" id="frmUpload"action="${url.context}/upload"     enctype="multipart/form-data" method="get">
<input type="file" size="40" id="toBeUploaded" name="toBeUploaded" tabindex="2" onchange = "document.getElementById('frmUpload').submit()"required />
</form>
I am creating a backed java webscript to get this file. Here is my java code.
public class Upload extends DeclarativeWebScript{
    protected ServiceRegistry serviceRegistry;
    private static final long serialVersionUID = 1L;
    private String fileName;
    private String filePath;
    private File toBeUploaded;  
    private String toBeUploadedFileName = "";  
    private String toBeUploadedContentType;  
    /** Multi-part form data, if provided */
    private FormData formData;
    /** Content read from the inputstream */
    private Content content = null;
    // upload settings
    private static final int MEMORY_THRESHOLD   = 1024 * 1024 * 3;  // 3MB
    private static final int MAX_FILE_SIZE      = 1024 * 1024 * 40; // 40MB
    private static final int MAX_REQUEST_SIZE   = 1024 * 1024 * 50; // 50MB
      @Override
      protected Map executeImpl(WebScriptRequest req,Status status) {         
          System.out.println("backed webscript called");
          Boolean isMultipart  = false;
          String fileName  = req.getParameter("toBeUploaded");        
          if(fileName == null){
              System.out.println("File Name is null");
          }else{
              System.out.println("File Name is :" + fileName);
          }       
          HttpServletRequest request = ServletUtil.getRequest();
          String file = request.getParameter("toBeUploaded");
          File file2 = new File(file);
          String filePath = request.getSession().getServletContext().getRealPath("/");        
          File fileToCreate = new File(filePath, this.toBeUploadedFileName);          
          System.out.println("filepath "+filePath);
          try {
                FileUtils.copyFile(file2, fileToCreate);
                //validateBundle(fileToCreate);
            } catch (IOException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            }
               System.out.println("filetocreate "+fileToCreate);
        }
}
file name is comming properly but it is throwing FileNotFoundExeption. Here is stacktrace
java.io.FileNotFoundException: Source 'test.jar' does not exist
        at org.apache.commons.io.FileUtils.copyFile(FileUtils.java:637)
        at org.apache.commons.io.FileUtils.copyFile(FileUtils.java:607)