|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectjavax.servlet.ServletRequestWrapper
javax.servlet.http.HttpServletRequestWrapper
org.wings.session.MultipartRequest
public final class MultipartRequest
A utility class to handle multipart/form-data requests, the kind of requests that support file uploads. This class can receive arbitrarily large files (up to an artificial limit you can set), and fairly efficiently too. And it knows and works around several browser bugs that don't know how to upload files correctly.
A client can upload files using an HTML form with the following structure. Note that not all browsers support file uploads.
<FORM ACTION="/servlet/Handler" METHOD=POST
ENCTYPE="multipart/form-data">
What is your name? <INPUT TYPE=TEXT NAME=submitter> <BR>
Which file to upload? <INPUT TYPE=FILE NAME=file> <BR>
<INPUT TYPE=SUBMIT>
</FORM>
The full file upload specification is contained in experimental RFC 1867,
available at
http://ds.internic.net/rfc/rfc1867.txt.
| Field Summary |
|---|
| Fields inherited from interface javax.servlet.http.HttpServletRequest |
|---|
BASIC_AUTH, CLIENT_CERT_AUTH, DIGEST_AUTH, FORM_AUTH |
| Constructor Summary | |
|---|---|
MultipartRequest(javax.servlet.http.HttpServletRequest request)
|
|
MultipartRequest(javax.servlet.http.HttpServletRequest request,
int maxPostSize)
|
|
| Method Summary | |
|---|---|
String |
getContentType(String name)
Returns the content type of the specified file (as supplied by the client browser), or null if the file was not included in the upload. |
File |
getFile(String name)
Returns a File object for the specified file saved on the server's filesystem, or null if the file was not included in the upload. |
String |
getFileId(String name)
Returns the fileid of the specified file, or null if the file was not included in the upload. |
String |
getFileName(String name)
Returns the filename of the specified file, or null if the file was not included in the upload. |
Iterator |
getFileNames()
Returns the names of all the uploaded files as an Enumeration of Strings. |
Map |
getParameterMap()
|
Enumeration |
getParameterNames()
Returns the names of all the parameters as an Enumeration of Strings. |
String[] |
getParameterValues(String name)
|
boolean |
isMultipart()
Indicates if this class was successfully able to parse request as multipart request. |
protected void |
processRequest(javax.servlet.http.HttpServletRequest req)
Parses passed request and stores contained parameters. |
protected void |
putParameter(String name,
String value)
Stores a parameter identified in this request. |
protected void |
setException(String param,
Exception ex)
Store exception as request parameter. |
| Methods inherited from class javax.servlet.http.HttpServletRequestWrapper |
|---|
getAuthType, getContextPath, getCookies, getDateHeader, getHeader, getHeaderNames, getHeaders, getIntHeader, getMethod, getPathInfo, getPathTranslated, getQueryString, getRemoteUser, getRequestedSessionId, getRequestURI, getRequestURL, getServletPath, getSession, getSession, getUserPrincipal, isRequestedSessionIdFromCookie, isRequestedSessionIdFromUrl, isRequestedSessionIdFromURL, isRequestedSessionIdValid, isUserInRole |
| Methods inherited from class javax.servlet.ServletRequestWrapper |
|---|
getAttribute, getAttributeNames, getCharacterEncoding, getContentLength, getContentType, getInputStream, getLocalAddr, getLocale, getLocales, getLocalName, getLocalPort, getParameter, getProtocol, getReader, getRealPath, getRemoteAddr, getRemoteHost, getRemotePort, getRequest, getRequestDispatcher, getScheme, getServerName, getServerPort, isSecure, removeAttribute, setAttribute, setCharacterEncoding, setRequest |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Methods inherited from interface javax.servlet.ServletRequest |
|---|
getAttribute, getAttributeNames, getCharacterEncoding, getContentLength, getContentType, getInputStream, getLocalAddr, getLocale, getLocales, getLocalName, getLocalPort, getParameter, getProtocol, getReader, getRealPath, getRemoteAddr, getRemoteHost, getRemotePort, getRequestDispatcher, getScheme, getServerName, getServerPort, isSecure, removeAttribute, setAttribute, setCharacterEncoding |
| Constructor Detail |
|---|
public MultipartRequest(javax.servlet.http.HttpServletRequest request)
throws IOException
request - the servlet request
IOException - if the uploaded content is larger than 1 Megabyte
or there's a problem reading or parsing the request
public MultipartRequest(javax.servlet.http.HttpServletRequest request,
int maxPostSize)
throws IOException
request - the servlet requestmaxPostSize - the maximum size of the POST content
IOException - if the uploaded content is larger than
maxPostSize or there's a problem reading or parsing the request| Method Detail |
|---|
public Enumeration getParameterNames()
getParameterNames in interface javax.servlet.ServletRequestgetParameterNames in class javax.servlet.ServletRequestWrapperpublic Iterator getFileNames()
public String[] getParameterValues(String name)
getParameterValues in interface javax.servlet.ServletRequestgetParameterValues in class javax.servlet.ServletRequestWrapperpublic Map getParameterMap()
getParameterMap in interface javax.servlet.ServletRequestgetParameterMap in class javax.servlet.ServletRequestWrapperpublic String getFileName(String name)
name - the file name
public String getFileId(String name)
name - the file name
public String getContentType(String name)
name - the file name
public File getFile(String name)
name - the file name
public final boolean isMultipart()
protected void setException(String param,
Exception ex)
protected void processRequest(javax.servlet.http.HttpServletRequest req)
throws IOException
IOException - On unrecoverable parsing bugs due to old Tomcat version.
protected void putParameter(String name,
String value)
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||