title: why doesn't the servlet retrieve the part ? It shows null as the file name
body: <p>The <em>html</em> snippet sends a <code>post</code> request to a <code>servlet</code> named <em>servlet</em>. The request is of type <code>multipart/form-data</code>.But servlet finds nothing and prints null for the name of the part I try to retrieve. Why is that ? </p>
  
  <pre><code>&lt;form method="post" action="servlet" enctype="multipart/form-data"&gt;
          &lt;input type="file" value="browse" name="FileShared" /&gt;
          &lt;input type="submit" value="submit" /&gt;
   &lt;/form&gt;
  </code></pre>
  
  <hr>
  
  <pre><code>import javax.servlet.http.Part;
  import javax.servlet.http.HttpServletRequest;
  import javax.servlet.http.HttpServletResponse;
  
      @Override
  protected void doPost(HttpServletRequest request, HttpServletResponse response)
          throws ServletException, IOException {
      response.setContentType("text/plain");
      //String fileName = request.getPart("FileShared").getName(); 
      // Throws a nullpointer exception if I don't comment the above statement
      PrintWriter writer = response.getWriter();
      //writer.println(fileName);
      Collection&lt;Part&gt; c = request.getParts();
      Iterator i = c.iterator();
      while(i.hasNext()) {
          writer.println("Inside while loop"); // This statement never gets printed
          writer.println(i.next());
      }
      writer.println("outside while loop"); // Only this statement gets printed
  }
  </code></pre>