Get HttpServletRequest in Struts 2 interceptor

You need to use ActionInvocation#getInvocationContext() to retrieve your request.

public String intercept(ActionInvocation invocation) throws Exception {
    ActionContext context = invocation.getInvocationContext();
    HttpServletRequest request = (HttpServletRequest) context.get(ServletActionContext.HTTP_REQUEST);
    // ...
}

The servlet stuff you could get referencing servletConfig interceptor. After this interceptor is invoked you could get servlet stuff from ServletActionContext.

HttpServletRequest request = ServletActionContext.getRequest();

Tags:

Java

Jsp

Struts2