title: Multipart Upload Servlet 3.0 - temporary files not deleting
body: <p>I have an upload servlet that is working great but leaves it's temporary files lying around. I am trying to use the part.delete() to clean them up as I go, but they are not deleting. </p>
  
  <p>The docs say the container will delete them when it does GC. But even if I wait an hour and eventually shut the server down, they are still there...</p>
  
  <p>What's the trick? It's Eclipse Kepler with Tomcat 7.0.47 on Windows for the moment. But production will be Linux.</p>
  
  <p>Thanks</p>
  
  <p>Code condensed substantially:</p>
  
  <pre><code>@MultipartConfig(location = "C:/tmp",
      fileSizeThreshold=1024*1024*10, // 10MB
      maxFileSize=1024*1024*10,      // 10MB
      maxRequestSize=1024*1024*50)   // 50MB
  @WebServlet("/upload.do")
  
      ...
  
  for (Part part : request.getParts()) {
      String filename = getFilename(part);
      if(!(filename==null)){
          part.write("/elsewhere/"+filename);
          part.delete();
      } else {
          out.println("skip field...");
      }
  }   
  </code></pre>