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 ; 10 import javax.servlet.http.HttpServletResponse ; 11 import java.util.HashMap ; 12 import java.util.Map ; 13 14 19 public class ContextUtil { 20 public static final String REQUEST = "req"; 21 public static final String REQUEST2 = "request"; 22 public static final String RESPONSE = "res"; 23 public static final String RESPONSE2 = "response"; 24 public static final String SESSION = "session"; 25 public static final String BASE = "base"; 26 public static final String STACK = "stack"; 27 public static final String OGNL = "ognl"; 28 public static final String WEBWORK = "webwork"; 29 public static final String ACTION = "action"; 30 31 public static Map getStandardContext(OgnlValueStack stack, HttpServletRequest req, HttpServletResponse res) { 32 HashMap map = new HashMap (); 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 |