Java Reference
In-Depth Information
maxRequestSize : The maximum size allowed for a multipart/form-
data request, in bytes. The web container will throw an exception if the overall
size of all uploaded files exceeds this threshold. The default size is unlimited.
For, example, the @MultipartConfig annotation could be constructed as follows:
Click here to view code image
@MultipartConfig(location="/tmp", fileSizeThreshold=1024*1024,
maxFileSize=1024*1024*5, maxRequestSize=1024*1024*5*5)
Instead of using the @MultipartConfig annotation to hard-code these attributes in
your file upload servlet, you could add the following as a child element of the servlet
configuration element in the web.xml file.
Click here to view code image
<multipart-config>
<location>/tmp</location>
<max-file-size>20848820</max-file-size>
<max-request-size>418018841</max-request-size>
<file-size-threshold>1048576</file-size-threshold>
</multipart-config>
The getParts and getPart Methods
Servlet 3.0 supports two additional HttpServletRequest methods:
Collection<Part> getParts()
Part getPart(String name)
The request.getParts() method returns collections of all Part objects. If you
have more than one input of type file , multiple Part objects are returned. Since
Part objects are named, the getPart(String name) method can be used to access
a particular Part . Alternatively, the getParts() method, which returns an Iter-
able<Part> , can be used to get an Iterator over all the Part objects.
The javax.servlet.http.Part interface is a simple one, providing methods that
allow introspection of each Part . The methods do the following:
• Retrieve the name, size, and content-type of the Part
• Query the headers submitted with a Part
• Delete a Part
• Write a Part out to disk
Search WWH ::




Custom Search