org.apache.struts.actions
public abstract class DownloadAction extends Action
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.
Since: Struts 1.2.6
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. |
Method Summary | |
---|---|
int | copy(InputStream input, OutputStream output)
Copy bytes from an InputStream to an
OutputStream .
|
ActionForward | execute(ActionMapping mapping, ActionForm form, HttpServletRequest request, 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, HttpServletRequest request, HttpServletResponse response)
Returns the information on the file, or other stream, to be downloaded
by this action. |
getBufferSize()
method is not overridden, this is
the buffer size that will be used to transfer the data to the servlet
output stream.InputStream
to an
OutputStream
.
Parameters: input The InputStream
to read from. output The OutputStream
to write to.
Returns: the number of bytes copied
Throws: IOException In case of an I/O problem
ActionForward
instance describing where and how
control should be forwarded, or null
if the response has
already been completed.
Parameters: 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.
Throws: Exception if an exception occurs.
Returns: The size of the transfer buffer, in bytes.
Parameters: 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.
Returns: The information for the file to be downloaded.
Throws: Exception if an exception occurs.