|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Object | +--de.opus5.servlet.MultipartRequest
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 |
MultipartRequest.BucketHash
Simple class for storing parameters |
| Constructor Summary | |
MultipartRequest(javax.servlet.ServletRequest sR,
int maxMemStoredReqSiz,
int maxReqSiz,
java.lang.String tmpDir,
java.lang.String uniquePrefix)
Create a MultipartRequest, temporary files will be deleted. |
|
MultipartRequest(javax.servlet.ServletRequest 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. |
|
MultipartRequest(javax.servlet.ServletRequest sR,
int maxReqSiz,
java.lang.String tmpDir,
java.lang.String uniquePrefix,
boolean keep)
Create a MultipartRequest, files will be saved to disk allways. |
|
MultipartRequest(javax.servlet.ServletRequest sR,
java.lang.String tmpDir,
java.lang.String uniquePrefix)
Create a MultipartRequest using the ServletRequest object, temporary files will be deleted. |
|
| Method Summary | |
java.lang.Object |
getAttribute(java.lang.String name)
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. |
java.io.File |
getFile(java.lang.String fieldname)
returns a java.io.File object if the file was saved on disk, null otherwise. |
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. |
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 |
getProtocol()
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 |
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. |
UploadedFile |
getUploadedFile(java.lang.String fieldname)
Get the UploadedFile object for the uploaded file with given name. |
| Methods inherited from class java.lang.Object |
clone,
equals,
finalize,
getClass,
hashCode,
notify,
notifyAll,
toString,
wait,
wait,
wait |
| Constructor Detail |
public MultipartRequest(javax.servlet.ServletRequest 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 MultipartRequest(javax.servlet.ServletRequest 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 MultipartRequest(javax.servlet.ServletRequest 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 MultipartRequest(javax.servlet.ServletRequest 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 namepublic 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()
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||