01: /*
02: * Copyright (c) 2002-2006 by OpenSymphony
03: * All rights reserved.
04: */
05: package com.opensymphony.webwork.interceptor;
06:
07: import org.apache.commons.logging.Log;
08: import org.apache.commons.logging.LogFactory;
09:
10: import com.opensymphony.webwork.ServletActionContext;
11: import com.opensymphony.xwork.ActionInvocation;
12: import com.opensymphony.xwork.interceptor.AroundInterceptor;
13:
14: /**
15: * <!-- START SNIPPET: description -->
16: *
17: * This interceptor creates the HttpSession.
18: * <p/>
19: * This is particular usefull when using the <@ww.tokten> tag in freemarker templates.
20: * The tag <b>do</b> require that a HttpSession is already created since freemarker commits
21: * the response to the client immediately.
22: *
23: * <!-- END SNIPPET: description -->
24: *
25: * <p/> <u>Interceptor parameters:</u>
26: *
27: *
28: * <!-- START SNIPPET: extending -->
29: *
30: * <ul>
31: * <li>none</li>
32: * </ul>
33: *
34: * <!-- END SNIPPET: extending -->
35: *
36: *
37: * <!-- START SNIPPET: parameters -->
38: *
39: * <ul>
40: *
41: * <li>None</li>
42: *
43: * </ul>
44: *
45: * <!-- END SNIPPET: parameters -->
46: *
47: * <b>Example:</b>
48: *
49: * <pre>
50: * <!-- START SNIPPET: example -->
51: *
52: * <action name="someAction" class="com.examples.SomeAction">
53: * <interceptor-ref name="create-session"/>
54: * <interceptor-ref name="defaultStack"/>
55: * <result name="input">input_with_token_tag.ftl</result>
56: * </action>
57: *
58: * <!-- END SNIPPET: example -->
59: * </pre>
60: *
61: * @author Claus Ibsen
62: * @version $Date: 2007-01-08 17:24:16 +0100 (Mon, 08 Jan 2007) $ $Id: CreateSessionInterceptor.java 2795 2007-01-08 16:24:16Z tmjee $
63: */
64: public class CreateSessionInterceptor extends AroundInterceptor {
65:
66: private static final long serialVersionUID = 3657994429041757752L;
67:
68: private static final Log _log = LogFactory
69: .getLog(CreateSessionInterceptor.class);
70:
71: protected void before(ActionInvocation invocation) throws Exception {
72: _log.debug("Creating HttpSession");
73: ServletActionContext.getRequest().getSession(true);
74: }
75:
76: protected void after(ActionInvocation dispatcher, String result)
77: throws Exception {
78: }
79: }
|