Package org.apache.struts2.interceptor

# Class CookieProviderInterceptor

java.lang.Object
org.apache.struts2.interceptor.AbstractInterceptor
org.apache.struts2.interceptor.CookieProviderInterceptor

All Implemented Interfaces:
  `Serializable`, `ConditionalInterceptor`, `Interceptor`, `PreResultListener`

public class CookieProviderInterceptor extends AbstractInterceptor implements PreResultListener
Allows actions to send cookies to client, action must implement `CookieProvider` You must reference this interceptor in your default stack or in action's stack, see example below. none

- addCookiesToResponse - this method applies cookie created by action to response

     <action ... >
       <interceptor-ref name="defaultStack"/>
       <interceptor-ref name="cookieProvider"/>
       ...
     </action>

See Also:
  - Serialized Form

- ## Constructor Summary

  Constructors
  Constructor
  Description
  `CookieProviderInterceptor()`

- ## Method Summary

  Modifier and Type
  Method
  Description
  `protected void`
  `addCookiesToResponse(CookieProvider action, jakarta.servlet.http.HttpServletResponse response)`
  Do what name suggests
  `void`
  `beforeResult(ActionInvocation invocation, String resultCode)`
  This callback method will be called after the `Action` execution and before the `Result` execution.
  `String`
  `intercept(ActionInvocation invocation)`
  Override to handle interception

  ### Methods inherited from class org.apache.struts2.interceptor.AbstractInterceptor

  `destroy, init, setDisabled, shouldIntercept`

  ### Methods inherited from class java.lang.Object

  `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- ## Constructor Details

  - ### CookieProviderInterceptor

    public CookieProviderInterceptor()

- ## Method Details

  - ### intercept

    public String intercept(ActionInvocation invocation) throws Exception
    Description copied from class: `AbstractInterceptor`
    Override to handle interception
    Specified by:
      `intercept` in interface `Interceptor`
    Specified by:
      `intercept` in class `AbstractInterceptor`
    Parameters:
      `invocation` - the action invocation
    Returns:
      the return code, either returned from `ActionInvocation.invoke()`, or from the interceptor itself.
    Throws:
      `Exception` - any system-level error, as defined in `Action.execute()`.

  - ### addCookiesToResponse

    protected void addCookiesToResponse(CookieProvider action, jakarta.servlet.http.HttpServletResponse response)
    Do what name suggests
    Parameters:
      `action` - `CookieProvider` action
      `response` - current `HttpServletResponse`

  - ### beforeResult

    public void beforeResult(ActionInvocation invocation, String resultCode)
    Description copied from interface: `PreResultListener`
    This callback method will be called after the `Action` execution and before the `Result` execution.
    Specified by:
      `beforeResult` in interface `PreResultListener`
    Parameters:
      `invocation` - the action invocation
      `resultCode` - the result code returned by the action (eg. `success`).