All Packages Class Hierarchy This Package Previous Next Index
java.lang.Object | +----com.oreilly.servlet.multipart.MultipartParser
multipart/form-data
requests,
the kind of requests that support file uploads. This class uses a
"pull" model where the reading of incoming files and parameters is
controlled by the client code, which allows incoming files to be stored
into any OutputStream
. If you wish to use an API which
resembles HttpServletRequest
, use the "push" model
MultipartRequest
instead. It's an easy-to-use wrapper
around this class.
This class can receive arbitrarily large files (up to an artificial limit you can set), and fairly efficiently too. It cannot handle nested data (multipart content within multipart content) or internationalized content (such as non Latin-1 filenames).
It also optionally includes enhanced buffering and Content-Length limitation. Buffering is only required if your servlet container is poorly implemented (many are, including Tomcat 3.2), but it is generally recommended because it will make a slow servlet container a lot faster, and will only make a fast servlet container a little slower. Content-Length limiting is usually only required if you find that your servlet is hanging trying to read the input stram from the POST, and it is similarly recommended because it only has a minimal impact on performance.
See the included upload.war for an example of how to use this class.
The full file upload specification is contained in experimental RFC 1867, available at http://www.ietf.org/rfc/rfc1867.txt.
MultipartParser
from the specified request,
which limits the upload size to the specified length, buffers for
performance and prevent attempts to read past the amount specified
by the Content-Length.
MultipartParser
from the specified request,
which limits the upload size to the specified length, and optionally
buffers for performance and prevents attempts to read past the amount
specified by the Content-Length.
public MultipartParser(HttpServletRequest req, int maxSize) throws IOException
MultipartParser
from the specified request,
which limits the upload size to the specified length, buffers for
performance and prevent attempts to read past the amount specified
by the Content-Length.
public MultipartParser(HttpServletRequest req, int maxSize, boolean buffer, boolean limitLength) throws IOException
MultipartParser
from the specified request,
which limits the upload size to the specified length, and optionally
buffers for performance and prevents attempts to read past the amount
specified by the Content-Length.
public Part readNextPart() throws IOException
FilePart
or a ParamPart
, or null
to indicate there are no more parts to read. The order of arrival
corresponds to the order of the form elements in the submitted form.
FilePart
, a ParamPart
or
null
if there are no more parts to read.
All Packages Class Hierarchy This Package Previous Next Index