|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.sun.rave.web.ui.util.UploadFilter
public class UploadFilter
Use the UploadFilter if your application contains an Upload component (<ui:upload> tag).
Configure the filter by declaring the filter element in the web application's deployment descriptor.
<filter> <filter-name>UploadFilter</filter-name> <filter-class>com.sun.rave.web.ui.util.UploadFilter</filter-class> </filter>
Map the filter to the FacesServlet, for example
<filter-mapping> <filter-name>UploadFilter</filter-name> <servlet-name>FacesServlet</servlet-name> </filter-mapping>
The UploadFilter uses the Apache commons fileupload package. You can configure the parameters of the DiskFileUpload class by specifying init parameters to the Filter. The following parameters are available:
maxSize
The maximum allowed upload size in bytes.
If negative, there is no maximum. The default value is 1,000,000.sizeThreshold
The implementation of the uploading
functionality uses temporary storage of the file contents before the
Upload component stores them per its configuration. In the temporary
storage, smaller files are stored in memory while larger files are
written directly to disk . Use this parameter
to specify an integer value of the cut-off where files should be
written to disk. The default value is 4096 bytes.tmpDir
Use this directory to specify the directory to
be used for temporary storage of files. The default behaviour is to use
the directory specified in the system property "java.io.tmpdir".
Field Summary | |
---|---|
static java.lang.String |
MAX_SIZE
The name of the filter init parameter used to specify the maximum allowable file upload size. |
static java.lang.String |
SIZE_THRESHOLD
The name of the filter init parameter used to specify the byte size above which temporary storage of files is on disk. |
static java.lang.String |
TMP_DIR
The name of the filter init parameter used to specify the directory to be used for temporary storage of uploaded files. |
Constructor Summary | |
---|---|
UploadFilter()
|
Method Summary | |
---|---|
void |
destroy()
Invoked when the Filter is destroyed |
void |
doFilter(javax.servlet.ServletRequest request,
javax.servlet.ServletResponse response,
javax.servlet.FilterChain chain)
The upload filter checks if the incoming request has multipart content. |
void |
init(javax.servlet.FilterConfig filterConfig)
Initializes the Upload filter by reading any init parameters. |
java.lang.String |
toString()
Return a String representation of the UploadFilter |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
public static final java.lang.String MAX_SIZE
public static final java.lang.String SIZE_THRESHOLD
public static final java.lang.String TMP_DIR
Constructor Detail |
---|
public UploadFilter()
Method Detail |
---|
public void doFilter(javax.servlet.ServletRequest request, javax.servlet.ServletResponse response, javax.servlet.FilterChain chain) throws java.io.IOException, javax.servlet.ServletException
The upload filter checks if the incoming request has multipart content. If it doesn't, the request is passed on as is to the next filter in the chain. If it does, the filter processes the request for form components. If it finds input from an Upload component, the file contents are stored for access by the Upload component's decode method.
For other form components, the input is processed and used to create a request parameter map. The original incoming request is wrapped, and the wrapped request is configured to use the created map. This means that subsequent filters in the chain (and Servlets, and JSPs) see the input from the other components as request parameters.
For advanced users: the UploadFilter uses the Apache commons FileUpload
package to process the file upload. When it detects input from an Upload
component, a org.apache.commons.fileupload.FileItem
is placed
in a request attribute whose name is the ID of the HTML input element
written by the Upload component.
doFilter
in interface javax.servlet.Filter
response
- The servlet responserequest
- The servlet request we are processingchain
- The filter chain we are processing
java.io.IOException
- if an input/output error occurs
javax.servlet.ServletException
- if a servlet error occurspublic void init(javax.servlet.FilterConfig filterConfig)
init
in interface javax.servlet.Filter
filterConfig
- the filter configurationpublic java.lang.String toString()
toString
in class java.lang.Object
public void destroy()
destroy
in interface javax.servlet.Filter
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |