<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
  <head>
    <meta content="text/html; charset=UTF-8" http-equiv="Content-Type" />

    <title>XMLmind MultipartRequest: an Open Source "multipart/form-data"
    request parser emulating the facilities found in the Servlet 3.0
    standard</title>

    <link href="resources/xmlmind.css" rel="stylesheet" type="text/css" />
  </head>

  <body><h1 class="xmtitle">Documentation</h1><blockquote
  class="xmnote"><p>The Home Page of XMLmind MultipartRequest is <a
  href="http://www.xmlmind.com/">http://www.xmlmind.com/</a>.<br />The history
  of changes is found <a href="#changes">below</a>.</p></blockquote><h2>What
  is XMLmind
  MultipartRequest?</h2><p><tt>com.xmlmind.multipartreq.MultipartRequest</tt>
  is a class derived from <tt>HttpServletRequestWrapper</tt>. It emulates the
  feature of the <a href="http://jcp.org/en/jsr/summary?id=315">Servlet
  3.0</a> standard which allows to support <tt>multipart/form-data</tt>
  requests without any additional component (e.g. <a
  href="http://www.servlets.com/cos/">com.oreilly.servlet</a>, <a
  href="http://commons.apache.org/fileupload/">Commons FileUpload</a>). Such
  feature is implemented by the means of the <tt>getPart</tt> and
  <tt>getParts</tt> methods of <tt>HttpServletRequest</tt> and the
  <tt>MultipartConfig</tt> annotation.</p><p>Unlike the Servlet 3.0 standard
  which requires you to use a recent Servlet container, XMLmind
  MultipartRequest is compatible with “old” <small>(that is, which implement
  at least the Servlet 2.3+ standard)</small> Servlet containers.</p><h2>Using
  XMLmind MultipartRequest</h2><p>Directory <tt>test_upload/</tt> contains the
  source code of a simple Servlet making use of XMLmind MultipartRequest.
  </p><p>The javadoc-generated reference manual of XMLmind MultipartRequest is
  found <a href="api/index.html">here</a>.</p><p>We recommend to integrate
  XMLmind MultipartRequest in your Servlet as follows (excerpts of
  <tt>test_upload/com/xmlmind/test_upload/TestUploadServlet.java</tt>):</p><pre>protected void <b>service</b>(HttpServletRequest req,
                       HttpServletResponse resp)
    throws ServletException, IOException {
    ServletContext context = getServletContext();
    HttpServletRequest req2 = req;
    Part[] parts = null;

    if (MultipartRequest.isMultipartRequest(req)) {
        MultipartRequest multipartReq = 
            new MultipartRequest(req, multipartConfig, context);
        try {
            parts = multipartReq.getParts();
        } catch (IllegalStateException e) {
            resp.sendError(HttpServletResponse.SC_REQUEST_ENTITY_TOO_LARGE,
                           e.getMessage());
            return;
        }

        req2 = multipartReq;
    }

    try {
        <b>super.service(req2, resp);</b>
    } finally {
        if (parts != null) {
            try {
                for (int i = 0; i &lt; parts.length; ++i) {
                    parts[i].delete();
                }
            } catch (Exception e) {
                String reason = e.getClass().getName();
                if (e.getMessage() != null) {
                    reason += ": " + e.getMessage();
                }

                context.log("cannot delete a part of a" +
                            " \"multipart/form-data\" request: " + reason,
                            e);
            }
        }
    }
}</pre><h2 id="changes">History of changes</h2><h3 id="v1.1.1">v1.1.1 (June
  07, 2017)</h3><p>Changed "Licensor" from "Pixware SARL" to "XMLmind
  Software" in all licenses.</p><h3 id="v1.1.0">v1.1 (July 4, 2015)</h3><ul>
      <li>Now implements <a
      href="http://www.w3.org/TR/html/forms.html#form-submission-0">HTML5 —
      Form submission — Multipart form data</a>, as the form submission
      algorithms (including the "<code>_charset_</code>" hidden field trick)
      described in this section seem to be implemented by all recent web
      browsers.</li>

      <li>Requires Java™ 1.6 in order to compile and run.</li>
    </ul><h3 id="v1.0.1">v1.0.1 (January 11, 2011)</h3><p>Bug fix: support for
  an Internet Explorer specificity. While uploading
  "<tt>multipart/form-data</tt>", <abbr>IE</abbr> transmits this kind of
  info:</p><pre>Content-Disposition: form-data; name="file0";
filename="C:\xmleditor_site\pages\buy.html"</pre><p>which was incorrectly
  parsed by XMLmind MultipartRequest.:</p><ul>
      <li><tt>req.getPart("file0")</tt> returned a <tt>Part</tt>, which is
      correct.</li>

      <li>But, <tt>req.getParameter("file0")</tt> returned
      <tt>"C:xmleditor_sitepagesbuy.html"</tt> instead of
      <tt>"buy.html"</tt>.</li>
    </ul><h3 id="v1.0.0">v1.0 (February 15, 2010)</h3><p>First
  release.</p></body>
</html>
