org.apache.struts2.interceptor

## Class CreateSessionInterceptor

- java.lang.Object
- - com.opensymphony.xwork2.interceptor.AbstractInterceptor
  - - org.apache.struts2.interceptor.CreateSessionInterceptor

- All Implemented Interfaces:
    Interceptor, Serializable

      public class CreateSessionInterceptor
      extends AbstractInterceptor

  This interceptor creates the HttpSession if it doesn't exist, also SessionMap is recreated and put in ServletActionContext.

  This is particular useful when using the <@s.token> tag in freemarker templates. The tag do require that a HttpSession is already created since freemarker commits the response to the client immediately.

  Interceptor parameters:

  - None
  - None

  Example:

       <action name="someAction" class="com.examples.SomeAction">
           <interceptor-ref name="createSession"/>
           <interceptor-ref name="defaultStack"/>
           <result name="input">input_with_token_tag.ftl</result>
       </action>

  See Also:
    Serialized Form

- - ### Constructor Summary

    Constructors
    Constructor and Description
    `CreateSessionInterceptor()`

  - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `String` | `intercept(ActionInvocation invocation)` Override to handle interception

    - ### Methods inherited from class com.opensymphony.xwork2.interceptor.AbstractInterceptor

      `destroy, init`

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

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

- - ### Constructor Detail

    - #### CreateSessionInterceptor

          public CreateSessionInterceptor()

  - ### Method Detail

    - #### 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()`.

Copyright © 2000–2022 Apache Software Foundation. All rights reserved.