|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.apache.struts.action.Action org.apache.struts.actions.BaseAction org.apache.struts.actions.DownloadAction
public abstract class DownloadAction
This is an abstract base class that minimizes the amount of special coding
that needs to be written to download a file. All that is required to use
this class is to extend it and implement the getStreamInfo()
method so that it returns the relevant information for the file (or other
stream) to be downloaded. Optionally, the getBufferSize()
method may be overridden to customize the size of the buffer used to
transfer the file.
Nested Class Summary | |
---|---|
static class |
DownloadAction.FileStreamInfo
A concrete implementation of the StreamInfo interface
which simplifies the downloading of a file from the disk. |
static class |
DownloadAction.ResourceStreamInfo
A concrete implementation of the StreamInfo interface
which simplifies the downloading of a web application resource. |
static interface |
DownloadAction.StreamInfo
The information on a file, or other stream, to be downloaded by the DownloadAction . |
Field Summary | |
---|---|
protected static int |
DEFAULT_BUFFER_SIZE
If the getBufferSize() method is not overridden, this is
the buffer size that will be used to transfer the data to the servlet
output stream. |
Fields inherited from class org.apache.struts.actions.BaseAction |
---|
messages |
Fields inherited from class org.apache.struts.action.Action |
---|
servlet |
Constructor Summary | |
---|---|
DownloadAction()
|
Method Summary | |
---|---|
int |
copy(java.io.InputStream input,
java.io.OutputStream output)
Copy bytes from an InputStream to an
OutputStream . |
ActionForward |
execute(ActionMapping mapping,
ActionForm form,
javax.servlet.http.HttpServletRequest request,
javax.servlet.http.HttpServletResponse response)
Process the specified HTTP request, and create the corresponding HTTP response (or forward to another web component that will create it). |
protected int |
getBufferSize()
Returns the size of the buffer to be used in transferring the data to the servlet output stream. |
protected abstract DownloadAction.StreamInfo |
getStreamInfo(ActionMapping mapping,
ActionForm form,
javax.servlet.http.HttpServletRequest request,
javax.servlet.http.HttpServletResponse response)
Returns the information on the file, or other stream, to be downloaded by this action. |
Methods inherited from class org.apache.struts.action.Action |
---|
addErrors, addMessages, execute, generateToken, getErrors, getLocale, getMessages, getResources, getResources, getServlet, isCancelled, isTokenValid, isTokenValid, resetToken, saveErrors, saveErrors, saveMessages, saveMessages, saveToken, setLocale, setServlet |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
protected static final int DEFAULT_BUFFER_SIZE
getBufferSize()
method is not overridden, this is
the buffer size that will be used to transfer the data to the servlet
output stream.
Constructor Detail |
---|
public DownloadAction()
Method Detail |
---|
protected abstract DownloadAction.StreamInfo getStreamInfo(ActionMapping mapping, ActionForm form, javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response) throws java.lang.Exception
mapping
- The ActionMapping used to select this instance.form
- The optional ActionForm bean for this request (if
any).request
- The HTTP request we are processing.response
- The HTTP response we are creating.
java.lang.Exception
- if an exception occurs.protected int getBufferSize()
public ActionForward execute(ActionMapping mapping, ActionForm form, javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response) throws java.lang.Exception
ActionForward
instance describing where and how
control should be forwarded, or null
if the response has
already been completed.
execute
in class Action
mapping
- The ActionMapping used to select this instance.form
- The optional ActionForm bean for this request (if
any).request
- The HTTP request we are processing.response
- The HTTP response we are creating.
null
if the response has been completed.
java.lang.Exception
- if an exception occurs.public int copy(java.io.InputStream input, java.io.OutputStream output) throws java.io.IOException
InputStream
to an
OutputStream
.
input
- The InputStream
to read from.output
- The OutputStream
to write to.
java.io.IOException
- In case of an I/O problem
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |