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 HttpHeaderResult

    java.lang.Object
      org.apache.struts2.dispatcher.HttpHeaderResult

All Implemented Interfaces:
  Result, java.io.Serializable

    public class HttpHeaderResult

extends java.lang.Object
implements Result

A custom Result type for setting HTTP headers and status by optionally evaluating against the ValueStack. This result can also be used to send and error to the client.

This result type takes the following parameters:

- status - the http servlet response status code that should be set on a response.
- parse - true by default. If set to false, the headers param will not be parsed for Ognl expressions.
- headers - header values.
- error - the http servlet response error code that should be set on a response.
- errorMessage - error message to be set on response if 'error' is set.

Example:

     <result name="success" type="httpheader">
       <param name="status">204</param>
       <param name="headers.a">a custom header value</param>
       <param name="headers.b">another custom header value</param>
     </result>

     <result name="proxyRequired" type="httpheader">
       <param name="error">305</param>
       <param name="errorMessage">this action must be accessed through a prozy</param>
     </result>

See Also:
  Serialized Form

Field Summary
`static java.lang.String` | `DEFAULT_PARAM` The default parameter

Constructor Summary
`HttpHeaderResult()`
`HttpHeaderResult(int status)`

Method Summary
`void` | `addHeader(java.lang.String name, java.lang.String value)` Adds an HTTP header to the response
`void` | `execute(ActionInvocation invocation)` Sets the optional HTTP response status code and also re-sets HTTP headers after they've been optionally evaluated against the ValueStack.
`java.util.Map` | `getHeaders()` Returns a Map of all HTTP headers.
`void` | `setError(int error)` Sets the http servlet error code that should be set on the reponse
`void` | `setErrorMessage(java.lang.String errorMessage)` Sets the error message that should be set on the reponse
`void` | `setParse(boolean parse)` Sets whether or not the HTTP header values should be evaluated against the ValueStack (by default they are).
`void` | `setStatus(int status)` Sets the http servlet response status code that should be set on a response.

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

Field Detail

### DEFAULT_PARAM

    public static final java.lang.String DEFAULT_PARAM

  The default parameter

  See Also:
    Constant Field Values

Constructor Detail

### HttpHeaderResult

    public HttpHeaderResult()

### HttpHeaderResult

    public HttpHeaderResult(int status)

Method Detail

### setError

    public void setError(int error)

  Sets the http servlet error code that should be set on the reponse

  Parameters:
    `error` - the Http error code
  See Also:
    `HttpServletResponse.sendError(int)`

### setErrorMessage

    public void setErrorMessage(java.lang.String errorMessage)

  Sets the error message that should be set on the reponse

  Parameters:
    `errorMessage` - error message send to the client
  See Also:
    `HttpServletResponse.sendError(int, String)`

### getHeaders

    public java.util.Map getHeaders()

  Returns a Map of all HTTP headers.

  Returns:
    a Map of all HTTP headers.

### setParse

    public void setParse(boolean parse)

  Sets whether or not the HTTP header values should be evaluated against the ValueStack (by default they are).

  Parameters:
    `parse` - `true` if HTTP header values should be evaluated agains the ValueStack, `false` otherwise.

### setStatus

    public void setStatus(int status)

  Sets the http servlet response status code that should be set on a response.

  Parameters:
    `status` - the Http status code
  See Also:
    `HttpServletResponse.setStatus(int)`

### addHeader

    public void addHeader(java.lang.String name,
                          java.lang.String value)

  Adds an HTTP header to the response

  Parameters:
    `name` -
    `value` -

### execute

    public void execute(ActionInvocation invocation)
                 throws java.lang.Exception

  Sets the optional HTTP response status code and also re-sets HTTP headers after they've been optionally evaluated against the ValueStack.

  Specified by:
    `execute` in interface `Result`
  Parameters:
    `invocation` - an encapsulation of the action execution state.
  Throws:
    `java.lang.Exception` - if an error occurs when re-setting the headers.

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-2011 Apache Software Foundation. All Rights Reserved.