KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > opensymphony > webwork > views > util > ContextUtil


1 package com.opensymphony.webwork.views.util;
2
3 import com.opensymphony.xwork.util.OgnlValueStack;
4 import com.opensymphony.xwork.ActionInvocation;
5 import com.opensymphony.xwork.ActionContext;
6 import com.opensymphony.webwork.views.jsp.ui.OgnlTool;
7 import com.opensymphony.webwork.util.WebWorkUtil;
8
9 import javax.servlet.http.HttpServletRequest JavaDoc;
10 import javax.servlet.http.HttpServletResponse JavaDoc;
11 import java.util.HashMap JavaDoc;
12 import java.util.Map JavaDoc;
13
14 /**
15  * User: plightbo
16  * Date: May 15, 2005
17  * Time: 6:02:38 PM
18  */

19 public class ContextUtil {
20     public static final String JavaDoc REQUEST = "req";
21     public static final String JavaDoc REQUEST2 = "request";
22     public static final String JavaDoc RESPONSE = "res";
23     public static final String JavaDoc RESPONSE2 = "response";
24     public static final String JavaDoc SESSION = "session";
25     public static final String JavaDoc BASE = "base";
26     public static final String JavaDoc STACK = "stack";
27     public static final String JavaDoc OGNL = "ognl";
28     public static final String JavaDoc WEBWORK = "webwork";
29     public static final String JavaDoc ACTION = "action";
30
31     public static Map JavaDoc getStandardContext(OgnlValueStack stack, HttpServletRequest JavaDoc req, HttpServletResponse JavaDoc res) {
32         HashMap JavaDoc map = new HashMap JavaDoc();
33         map.put(REQUEST, req);
34         map.put(REQUEST2, req);
35         map.put(RESPONSE, res);
36         map.put(RESPONSE2, res);
37         map.put(SESSION, req.getSession(false));
38         map.put(BASE, req.getContextPath());
39         map.put(STACK, stack);
40         map.put(OGNL, OgnlTool.getInstance());
41         map.put(WEBWORK, new WebWorkUtil(stack, req, res));
42
43         ActionInvocation invocation = (ActionInvocation) stack.getContext().get(ActionContext.ACTION_INVOCATION);
44         if (invocation != null) {
45             map.put(ACTION, invocation.getAction());
46         }
47
48
49         return map;
50     }
51 }
52
Popular Tags