Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## org.apache.struts2.dispatcher
Class StreamResult

    java.lang.Object
      org.apache.struts2.dispatcher.StrutsResultSupport
          org.apache.struts2.dispatcher.StreamResult

All Implemented Interfaces:
  Result, Serializable, StrutsStatics

    public class StreamResult

extends StrutsResultSupport

A custom Result type for send raw data (via an InputStream) directly to the HttpServletResponse. Very useful for allowing users to download content.

This result type takes the following parameters:

- contentType - the stream mime-type as sent to the web browser (default = `text/plain`).
- contentLength - the stream length in bytes (the browser displays a progress bar).
- contentDispostion - the content disposition header value for specifing the file name (default = `inline`, values are typically filename="document.pdf".
- inputName - the name of the InputStream property from the chained action (default = `inputStream`).
- bufferSize - the size of the buffer to copy from input to output (default = `1024`).

Example:

     <result name="success" type="stream">
       <param name="contentType">image/jpeg</param>
       <param name="inputName">imageStream</param>
       <param name="contentDisposition">filename="document.pdf"</param>
       <param name="bufferSize">1024</param>
     </result>

See Also:
  Serialized Form

Field Summary
`protected int` | `bufferSize`
`protected String` | `contentDisposition`
`protected String` | `contentLength`
`protected String` | `contentType`
`static String` | `DEFAULT_PARAM`
`protected String` | `inputName`
`protected InputStream` | `inputStream`
`protected static Log` | `log`
`private static long` | `serialVersionUID`

Fields inherited from interface org.apache.struts2.StrutsStatics
`HTTP_REQUEST, HTTP_RESPONSE, PAGE_CONTEXT, SERVLET_CONTEXT, SERVLET_DISPATCHER, STRUTS_PORTLET_CONTEXT`

Constructor Summary
`StreamResult()`
`StreamResult(InputStream in)`

Method Summary
`protected void` | `doExecute(String finalLocation, ActionInvocation invocation)` Executes the result given a final location (jsp page, action, etc) and the action invocation (the state in which the action was executed).
`int` | `getBufferSize()`
`String` | `getContentDisposition()`
`String` | `getContentLength()`
`String` | `getContentType()`
`String` | `getInputName()`
`void` | `setBufferSize(int bufferSize)`
`void` | `setContentDisposition(String contentDisposition)`
`void` | `setContentLength(String contentLength)`
`void` | `setContentType(String contentType)`
`void` | `setInputName(String inputName)`

Methods inherited from class org.apache.struts2.dispatcher.StrutsResultSupport
`conditionalParse, execute, getLastFinalLocation, setEncode, setLocation, setParse`

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Field Detail

### serialVersionUID

    private static final long serialVersionUID

See Also:
  Constant Field Values

### log

    protected static final Log log

### DEFAULT_PARAM

    public static final String DEFAULT_PARAM

See Also:
  Constant Field Values

### contentType

    protected String contentType

### contentLength

    protected String contentLength

### contentDisposition

    protected String contentDisposition

### inputName

    protected String inputName

### inputStream

    protected InputStream inputStream

### bufferSize

    protected int bufferSize

Constructor Detail

### StreamResult

    public StreamResult()

### StreamResult

    public StreamResult(InputStream in)

Method Detail

### getBufferSize

    public int getBufferSize()

  Returns:
    Returns the bufferSize.

### setBufferSize

    public void setBufferSize(int bufferSize)

  Parameters:
    `bufferSize` - The bufferSize to set.

### getContentType

    public String getContentType()

  Returns:
    Returns the contentType.

### setContentType

    public void setContentType(String contentType)

  Parameters:
    `contentType` - The contentType to set.

### getContentLength

    public String getContentLength()

  Returns:
    Returns the contentLength.

### setContentLength

    public void setContentLength(String contentLength)

  Parameters:
    `contentLength` - The contentLength to set.

### getContentDisposition

    public String getContentDisposition()

  Returns:
    Returns the Content-disposition header value.

### setContentDisposition

    public void setContentDisposition(String contentDisposition)

  Parameters:
    `contentDisposition` - the Content-disposition header value to use.

### getInputName

    public String getInputName()

  Returns:
    Returns the inputName.

### setInputName

    public void setInputName(String inputName)

  Parameters:
    `inputName` - The inputName to set.

### doExecute

    protected void doExecute(String finalLocation,
                             ActionInvocation invocation)
                      throws Exception

  Description copied from class: `StrutsResultSupport`
  Executes the result given a final location (jsp page, action, etc) and the action invocation (the state in which the action was executed). Subclasses must implement this class to handle custom logic for result handling.

  Specified by:
    `doExecute` in class `StrutsResultSupport`
  Parameters:
    `finalLocation` - the location (jsp page, action, etc) to go to.
    `invocation` - the execution state of the action.
  Throws:
    `Exception` - if an error occurs while executing the result.
  See Also:
    `StrutsResultSupport.doExecute(java.lang.String, com.opensymphony.xwork2.ActionInvocation)`

Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

Copyright © 2000-2007 Apache Software Foundation. All Rights Reserved.