FileDocCategorySizeDatePackage
ServletActionContext.javaAPI DocExample4826Mon Jul 23 13:26:56 BST 2007org.apache.struts2

ServletActionContext

public class ServletActionContext extends com.opensymphony.xwork2.ActionContext implements StrutsStatics
Web-specific context information for actions. This class subclasses ActionContext which provides access to things like the action name, value stack, etc. This class adds access to web objects like servlet parameters, request attributes and things like the HTTP session.

Fields Summary
private static final long
serialVersionUID
public static final String
STRUTS_VALUESTACK_KEY
public static final String
ACTION_MAPPING
Constructors Summary
private ServletActionContext(Map context)

        super(context);
    
Methods Summary
public static com.opensymphony.xwork2.ActionContextgetActionContext(javax.servlet.http.HttpServletRequest req)
Gets the current action context

param
req The request
return
The current action context

        ValueStack vs = getValueStack(req);
        if (vs != null) {
            return new ActionContext(vs.getContext());
        } else {
            return null;
        }
    
public static org.apache.struts2.dispatcher.mapper.ActionMappinggetActionMapping()
Gets the action mapping for this context

return
The action mapping

        return (ActionMapping) ActionContext.getContext().get(ACTION_MAPPING);
    
public static javax.servlet.jsp.PageContextgetPageContext()
Returns the HTTP page context.

return
the HTTP page context.

        return (PageContext) ActionContext.getContext().get(PAGE_CONTEXT);
    
public static javax.servlet.http.HttpServletRequestgetRequest()
Gets the HTTP servlet request object.

return
the HTTP servlet request object.

        return (HttpServletRequest) ActionContext.getContext().get(HTTP_REQUEST);
    
public static javax.servlet.http.HttpServletResponsegetResponse()
Gets the HTTP servlet response object.

return
the HTTP servlet response object.

        return (HttpServletResponse) ActionContext.getContext().get(HTTP_RESPONSE);
    
public static javax.servlet.ServletContextgetServletContext()
Gets the servlet context.

return
the servlet context.

        return (ServletContext) ActionContext.getContext().get(SERVLET_CONTEXT);
    
public static com.opensymphony.xwork2.util.ValueStackgetValueStack(javax.servlet.http.HttpServletRequest req)
Gets the current value stack for this request

param
req The request
return
The value stack

        return (ValueStack) req.getAttribute(STRUTS_VALUESTACK_KEY);
    
public static voidsetRequest(javax.servlet.http.HttpServletRequest request)
Sets the HTTP servlet request object.

param
request the HTTP servlet request object.

        ActionContext.getContext().put(HTTP_REQUEST, request);
    
public static voidsetResponse(javax.servlet.http.HttpServletResponse response)
Sets the HTTP servlet response object.

param
response the HTTP servlet response object.

        ActionContext.getContext().put(HTTP_RESPONSE, response);
    
public static voidsetServletContext(javax.servlet.ServletContext servletContext)
Sets the current servlet context object

param
servletContext The servlet context to use

        ActionContext.getContext().put(SERVLET_CONTEXT, servletContext);