title: How to get files from HttpServletRequest in Java Servlet
body: <p>The form in the HTML is like</p>
  
  <pre><code>...
  &lt;form method="post" action="/foobar"&gt;
    &lt;input type="file" name="attachment" /&gt;
    &lt;input type="text" name="foo" /&gt;
    ... other input fields
  &lt;/form&gt;
  </code></pre>
  
  <p>And the Servlet will be like</p>
  
  <pre><code>@Override
  protected void doPost(HttpServletRequest request, HttpServletResponse response)
          throws ServletException, IOException {
      String attachment = request.getParameter("attachement");
      String foo = request.getParameter("foo");
      // get other parameters from the request
      // and get the attachment file
  }
  </code></pre>
  
  <p>And I'm wondering</p>
  
  <ol>
  <li><p>Is there any ways that do not use 3rd-party libraries to get files from a <code>HttpServletRequest</code> object?</p></li>
  <li><p>What <code>request.getParameter("attachement")</code> returns? Is it the file name or something else?</p></li>
  <li><p>Would the binary input be stored automatically by a web container in file system or just in memory temporarily?</p></li>
  </ol>