/** * Gets the name of the current Action. * * @return the name of the current action. */ public String getName() { return (String) get(ACTION_NAME); }
/** * Gets the shared lifecycle for this request * * @return The lifecycle */ private Lifecycle getLifecycle() { return (Lifecycle) ActionContext.getContext().get(LIFECYCLE_KEY); }
/** * Get the XWork chain history. * The stack is a list of <code>namespace/action!method</code> keys. */ public static LinkedList<String> getChainHistory() { LinkedList<String> chainHistory = (LinkedList<String>) ActionContext.getContext().get(CHAIN_HISTORY); // Add if not exists if (chainHistory == null) { chainHistory = new LinkedList<String>(); ActionContext.getContext().put(CHAIN_HISTORY, chainHistory); } return chainHistory; }
/** * Gets the Map of HttpSession values when in a servlet environment or a generic session map otherwise. * * @return the Map of HttpSession values when in a servlet environment or a generic session map otherwise. */ public Map<String, Object> getSession() { return (Map<String, Object>) get(SESSION); }
public void clearSessionValue() { HttpServletRequest request = (HttpServletRequest) ActionContext.getContext() .get("com.opensymphony.xwork2.dispatcher.HttpServletRequest"); for (Enumeration<String> e = request.getSession().getAttributeNames(); e.hasMoreElements();) { String key = e.nextElement(); if (key.indexOf("class") >= 0) { request.getSession().removeAttribute(key); } } }
/** * Returns a Map of the ServletContext when in a servlet environment or a generic application level Map otherwise. * * @return a Map of ServletContext or generic application level Map */ public Map<String, Object> getApplication() { return (Map<String, Object>) get(APPLICATION); }
/** * Sets the container for this request * * @return The container */ public Container getContainer() { return (Container) get(CONTAINER); }
/*************************************************************************** * Static Methods **************************************************************************/ public static AgiRequest getAgiRequest(ActionContext context) { return (AgiRequest) context.get(AGI_REQUEST_PARAM); }
/** * Gets the action invocation (the execution state). * * @return the action invocation (the execution state). */ public ActionInvocation getActionInvocation() { return (ActionInvocation) get(ACTION_INVOCATION); }
/** * Determines whether to process this request with the JSF phases * * @param ctx The current action context * @return True if it is a faces-enabled request */ protected boolean isFacesEnabled(ActionContext ctx) { return ctx.get(FACES_ENABLED) != null; }
/** * Returns a Map of the HttpServletRequest parameters when in a servlet environment or a generic Map of * parameters otherwise. * * @return a Map of HttpServletRequest parameters or a multipart map when in a servlet environment, or a * generic Map of parameters otherwise. */ public Map<String, Object> getParameters() { return (Map<String, Object>) get(PARAMETERS); }
/** * Gets the OGNL value stack. * * @return the OGNL value stack. */ public ValueStack getValueStack() { return (ValueStack) get(VALUE_STACK); }
public String intercept(ActionInvocation invocation) throws Exception { ActionContext context = invocation.getInvocationContext(); HttpServletRequest request = (HttpServletRequest) context.get(HTTP_REQUEST); // ... }
public String intercept(ActionInvocation Invocation) throws Exception { final ActionContext ac = invocation.getInvocationContext(); HttpServletResponse response = (HttpServletResponse) ac.get(StrutsStatics.HTTP_RESPONSE); //HttpServletResponse response = ServletActionContext.getResponse(); response.addHeader("X-Frame-Options", "SAMEORIGIN"); response.addHeader("Content-Security-Policy-Report-Only", "default-src 'self'; script-src 'self' 'unsafe-inline'; object-src 'none'; style-src 'self' 'unsafe-inline'; img-src 'self'; media-src 'none'; frame-src 'none'; font-src 'self'; connect-src 'self'; report-uri REDACTED"); response.addHeader("X-Content-Security-Policy-Report-Only", "default-src 'self'; script-src 'self' 'unsafe-inline'; object-src 'none'; style-src 'self' 'unsafe-inline'; img-src 'self'; media-src 'none'; frame-src 'none'; font-src 'self'; connect-src 'self'; report-uri REDACTED"); return Invocation.invoke(); }
@Override public String intercept(ActionInvocation ai) throws Exception { final ActionContext context = ai.getInvocationContext(); HttpServletRequest request = (HttpServletRequest)context.get(StrutsStatics.HTTP_REQUEST); request.setAttribute("redirUrl", "http://the.new.target.org"); return "redir"; }
@Override protected String doIntercept(ActionInvocation actionInvocation) throws Exception { String invoke = actionInvocation.invoke(); HttpServletResponse response = (HttpServletResponse) actionInvocation.getInvocationContext() .get(StrutsStatics.HTTP_RESPONSE); log.debug("Set struts header response status to: {}", response.getStatus()); response.addHeader(HEADER_STRUTS_STATUS_CODE, "" + response.getStatus()); return invoke; } }
public String intercept(ActionInvocation actionInvocation) throws Exception { ActionContext sessionAttributes = actionInvocation.getInvocationContext(); Object sess = sessionAttributes.get("userid"); if (sess == null) { if (sessionAttributes.get("userId") != null) { result = actionInvocation.invoke(); } return result; } return actionInvocation.invoke(); }
public String intercept(ActionInvocation invocation) throws Exception { final ActionContext context = invocation.getInvocationContext(); Map<String,Object> parameters = (Map<String,Object>)context.get(ActionContext.PARAMETERS); Map<String, Object> parametersCopy = new HashMap<String, Object>(); parametersCopy.putAll(parameters); parametersCopy.put("myParam", "changedValue"); context.put(ActionContext.PARAMETERS, parametersCopy); return invocation.invoke(); }
@Override public void execute(ActionInvocation actionInvocation) throws Exception { ActionContext context = actionInvocation.getInvocationContext(); HttpServletRequest request = (HttpServletRequest) context.get(ServletActionContext.HTTP_REQUEST); HttpServletResponse response = (HttpServletResponse) context.get(ServletActionContext.HTTP_RESPONSE); String location = createRedirectLocation(request); // append the conversation id to the redirect url String locationWithConversationIds = RedirectUtil.getUrlParamString(location, ConversationAdapter.getAdapter().getViewContext()); String finalLocation = response.encodeRedirectURL(locationWithConversationIds); response.sendRedirect(finalLocation); }
public void beforeResult(ActionInvocation invocation, String resultCode) { Map<Object, Object> fakie = (Map<Object, Object>) invocation.getInvocationContext().get(ORIGINAL_PROPERTY_OVERRIDE); if (fakie != null) { invocation.getStack().setExprOverrides(fakie); } } });