|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Object | +--de.opus5.servlet.HttpMultipartRequest
A class for handling multipart form uploads. Unlike com.oreilly.servlet.MultipartRequest this class returns a InputStream for reading the file's content, so you can also write the data into magic crystals instead of writing it to the file system. ;) There is also the option to save files to disk and return a java.io.File object. You can also access the file data via the getUploadedFile() method, which returns an file object implementing the de.opus5.servlet.UploadedFile interface. The class can decide based on the total request size if the file data is temporary stored in memory or in the file system.
Example:
MulipartRequest req;
..
try {
req = new MultipartRequest(servletRequest,maxMemoryStoredRequestSize,
tmpdir,fileprefix);
} catch (Exception e) {
...
}
....
filename = req.getUploadedFile("Document").getName();
is = req.getInputStreamForFile("Document");
while (is.read()...) {
...
}
login = req.getParameter("Login");
...
UploadedFile adressFile = mReq.getUploadedFile(Global.MPADRESSF_KEY);
UploadedFile docFile = mReq.getUploadedFile(Global.MPDOCFILE_KEY);
myObject.setAdressFile(adressFile);
....
....
| Inner Class Summary | |
class |
HttpMultipartRequest.BucketHash
Simple class for storing parameters |
| Constructor Summary | |
HttpMultipartRequest(javax.servlet.http.HttpServletRequest sR,
int maxMemStoredReqSiz,
int maxReqSiz,
java.lang.String tmpDir,
java.lang.String uniquePrefix)
Create a MultipartRequest, temporary files will be deleted. |
|
HttpMultipartRequest(javax.servlet.http.HttpServletRequest sR,
int maxMemStoredReqSiz,
java.lang.String tmpDir,
java.lang.String uniquePrefix)
Create a MultipartRequest, temporary files will be deleted, the maximum request size is set to 1MB. |
|
HttpMultipartRequest(javax.servlet.http.HttpServletRequest sR,
int maxReqSiz,
java.lang.String tmpDir,
java.lang.String uniquePrefix,
boolean keep)
Create a MultipartRequest, files will be saved to disk allways. |
|
HttpMultipartRequest(javax.servlet.http.HttpServletRequest sR,
java.lang.String tmpDir,
java.lang.String uniquePrefix)
Create a MultipartRequest using the ServletRequest object, temporary files will be deleted. |
|
| Method Summary | |
void |
copyFile(java.lang.String fieldname,
java.lang.String filename)
Copies an uploaded file into the specified file. |
java.lang.Object |
getAttribute(java.lang.String name)
Calls the corresponding method in ServletRequest-object. |
java.lang.String |
getAuthType()
Calls the corresponding method in ServletRequest-object. |
java.lang.String |
getCharacterEncoding()
Calls the corresponding method in ServletRequest-object. |
int |
getContentLength()
Calls the corresponding method in ServletRequest-object. |
java.lang.String |
getContentType()
Calls the corresponding method in ServletRequest-object. |
javax.servlet.http.Cookie[] |
getCookies()
Calls the corresponding method in ServletRequest-object. |
long |
getDateHeader(java.lang.String name)
Calls the corresponding method in ServletRequest-object. |
java.io.File |
getFile(java.lang.String fieldname)
returns a java.io.File object if the file was saved on disk, null otherwise. |
java.lang.String |
getHeader(java.lang.String name)
Calls the corresponding method in ServletRequest-object. |
java.util.Enumeration |
getHeaderNames()
Calls the corresponding method in ServletRequest-object. |
javax.servlet.ServletInputStream |
getInputStream()
Calls the corresponding method in ServletRequest-object. |
java.io.InputStream |
getInputStreamForFile(java.lang.String fieldname)
return an InputStream for reading an uploaded file. |
int |
getIntHeader(java.lang.String name)
Calls the corresponding method in ServletRequest-object. |
java.lang.String |
getMethod()
Calls the corresponding method in ServletRequest-object. |
java.lang.String |
getParameter(java.lang.String name)
return the value of parameter with specified name |
java.util.Enumeration |
getParameterNames()
return the names of all parameters as Enumeration |
java.lang.String[] |
getParameterValues(java.lang.String name)
return the value of the specified parameter as an array of strings. |
java.lang.String |
getPathInfo()
Calls the corresponding method in ServletRequest-object. |
java.lang.String |
getPathTranslated()
Calls the corresponding method in ServletRequest-object. |
java.lang.String |
getProtocol()
Calls the corresponding method in ServletRequest-object. |
java.lang.String |
getQueryString()
Calls the corresponding method in ServletRequest-object. |
java.io.BufferedReader |
getReader()
Calls the corresponding method in ServletRequest-object. |
java.lang.String |
getRealPath(java.lang.String path)
Calls the corresponding method in ServletRequest-object. |
java.lang.String |
getRemoteAddr()
Calls the corresponding method in ServletRequest-object. |
java.lang.String |
getRemoteHost()
Calls the corresponding method in ServletRequest-object. |
java.lang.String |
getRemoteUser()
Calls the corresponding method in ServletRequest-object. |
java.lang.String |
getRequestedSessionId()
Calls the corresponding method in ServletRequest-object. |
java.lang.String |
getRequestURI()
Calls the corresponding method in ServletRequest-object. |
java.lang.String |
getScheme()
Calls the corresponding method in ServletRequest-object. |
java.lang.String |
getServerName()
Calls the corresponding method in ServletRequest-object. |
int |
getServerPort()
Calls the corresponding method in ServletRequest-object. |
java.lang.String |
getServletPath()
Calls the corresponding method in ServletRequest-object. |
javax.servlet.http.HttpSession |
getSession(boolean create)
Calls the corresponding method in ServletRequest-object. |
UploadedFile |
getUploadedFile(java.lang.String fieldname)
Get the UploadedFile object for the uploaded file with given name. |
boolean |
isRequestedSessionIdFromCookie()
Calls the corresponding method in ServletRequest-object. |
boolean |
isRequestedSessionIdFromUrl()
Calls the corresponding method in ServletRequest-object. |
boolean |
isRequestedSessionIdValid()
Calls the corresponding method in ServletRequest-object. |
| Methods inherited from class java.lang.Object |
clone,
equals,
finalize,
getClass,
hashCode,
notify,
notifyAll,
toString,
wait,
wait,
wait |
| Constructor Detail |
public HttpMultipartRequest(javax.servlet.http.HttpServletRequest sR,
int maxMemStoredReqSiz,
int maxReqSiz,
java.lang.String tmpDir,
java.lang.String uniquePrefix)
throws java.lang.IllegalArgumentException,
java.io.IOException
sR - the ServletRequestmaxMemStoredReqSiz - If the request size in bytes exceeds
this value, the uploaded files will be stored on disk.maxReqSiz - Maximum size of request.tmpDir - Directory where temporary files are saved.uniquePrefix - Prefix added to the filenames to prevent
overwriting of files with the same name.
public HttpMultipartRequest(javax.servlet.http.HttpServletRequest sR,
int maxMemStoredReqSiz,
java.lang.String tmpDir,
java.lang.String uniquePrefix)
throws java.lang.IllegalArgumentException,
java.io.IOException
sR - the ServletRequestmaxMemStoredReqSiz - If the request size in bytes exceeds
this value, the uploaded files will be stored on disk.tmpDir - Directory where temporary files are saved.uniquePrefix - Prefix added to the filenames to prevent
overwriting of files with the same name.
public HttpMultipartRequest(javax.servlet.http.HttpServletRequest sR,
int maxReqSiz,
java.lang.String tmpDir,
java.lang.String uniquePrefix,
boolean keep)
throws java.lang.IllegalArgumentException,
java.io.IOException
sR - the ServletRequestmaxReqSiz - Maximum size of request.tmpDir - Directory where temporary files are saved.uniquePrefix - Prefix added to the filenames to prevent
overwriting of files with the same name.keep - If set, the uploaded files will not be deleted.
public HttpMultipartRequest(javax.servlet.http.HttpServletRequest sR,
java.lang.String tmpDir,
java.lang.String uniquePrefix)
throws java.lang.IllegalArgumentException,
java.io.IOException
sR - the ServletRequesttmpDir - Directory where temporary files are saved.uniquePrefix - Prefix added to the filenames to prevent
overwriting of files with the same name.| Method Detail |
public java.io.File getFile(java.lang.String fieldname)
fieldname - the form parameter field name
public java.io.InputStream getInputStreamForFile(java.lang.String fieldname)
throws java.io.IOException
filename - the form parameter field name
public void copyFile(java.lang.String fieldname,
java.lang.String filename)
throws java.io.IOException
fieldname - the form parameter field namefilename - the name of the targetpublic java.util.Enumeration getParameterNames()
public java.lang.String getParameter(java.lang.String name)
name - the parameter namepublic java.lang.String[] getParameterValues(java.lang.String name)
public UploadedFile getUploadedFile(java.lang.String fieldname)
fieldname - the form parameter field namepublic java.lang.Object getAttribute(java.lang.String name)
public int getContentLength()
public java.lang.String getContentType()
public java.lang.String getProtocol()
public java.lang.String getScheme()
public java.lang.String getServerName()
public int getServerPort()
public java.lang.String getRemoteAddr()
public java.lang.String getRemoteHost()
public java.lang.String getRealPath(java.lang.String path)
public javax.servlet.ServletInputStream getInputStream()
throws java.io.IOException
public java.io.BufferedReader getReader()
throws java.io.IOException
public java.lang.String getCharacterEncoding()
public javax.servlet.http.Cookie[] getCookies()
public java.lang.String getMethod()
public java.lang.String getRequestURI()
public java.lang.String getServletPath()
public java.lang.String getPathInfo()
public java.lang.String getQueryString()
public java.lang.String getPathTranslated()
public java.lang.String getRemoteUser()
public java.lang.String getAuthType()
public java.lang.String getHeader(java.lang.String name)
public int getIntHeader(java.lang.String name)
public long getDateHeader(java.lang.String name)
public java.util.Enumeration getHeaderNames()
public javax.servlet.http.HttpSession getSession(boolean create)
public java.lang.String getRequestedSessionId()
public boolean isRequestedSessionIdValid()
public boolean isRequestedSessionIdFromCookie()
public boolean isRequestedSessionIdFromUrl()
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||