title: Java - file upload problem
body: <p>Servlet</p>
  
  <pre><code>import java.io.*;
  import javax.servlet.*;
  import javax.servlet.http.*;
  import java.util.Iterator;
  import java.util.List;
  import org.apache.commons.fileupload.servlet.ServletFileUpload;
  import org.apache.commons.fileupload.disk.DiskFileItemFactory;
  import org.apache.commons.fileupload.*;
  
  public class Apply extends HttpServlet
  {
      protected void doPost(HttpServletRequest request, HttpServletResponse response)
                              throws ServletException, IOException
      {
          InputStreamReader input = new InputStreamReader(request.getInputStream());
          BufferedReader buffer = new BufferedReader(input);
          String line="";
          line=buffer.readLine();
  
          System.out.println("Multipart data " + line );
  
          boolean isMultipart = ServletFileUpload.isMultipartContent(request);
          if(isMultipart)
          {
              // upload file
          }
          else
          {
              // failed, no input
          }
      }
  
      protected void doGet(HttpServletRequest request, HttpServletResponse response)
                              throws ServletException, IOException
      {
          doPost(request, response);
      }
  }
  </code></pre>
  
  <p>JSP.</p>
  
  <pre><code>        &lt;form enctype="multipart/form-data" method="post" action="apply"&gt;
              &lt;fieldset&gt;
                  &lt;br/&gt;
                  &lt;legend&gt;Upload&lt;/legend&gt;
                  &lt;br/&gt;
                  &lt;label&gt;Select file to upload&lt;/label&gt;
                  &lt;input type="file" name="file" /&gt;&lt;br /&gt;
                  &lt;br/&gt;
                  &lt;a href="apply" class="jUiButton"&gt;Submit&lt;/a&gt;
              &lt;/fieldset&gt;
          &lt;/form&gt;     
          &lt;script&gt;$(".jUiButton").button()&lt;/script&gt;
  </code></pre>
  
  <p>The boolean and input always validates as false/null and I can't figure why. Following this guide: <a href="http://sacharya.com/file-upload/" rel="nofollow">http://sacharya.com/file-upload/</a></p>
  
  <p>in the web-inf/lib - we have commons-fileupload-1.2.2.jar and commons-io-2.0.1.jar.</p>
  
  <p>Any ideas?</p>