The form in the HTML is like

...
<form method="post" action="/foobar">
  <input type="file" name="attachment" />
  <input type="text" name="foo" />
  ... other input fields
</form>

And the Servlet will be like

@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
}

And I'm wondering

  1. Is there any ways that do not use 3rd-party libraries to get files from a HttpServletRequest object?

  2. What request.getParameter("attachement") returns? Is it the file name or something else?

  3. Would the binary input be stored automatically by a web container in file system or just in memory temporarily?

Edit
Report