Obviously the request variable's value is null since it has not been set to anything. Actions in Struts2 are not servlets.
In order to access the servlet request, your action needs to implement the RequestAware interface. Please refer to the following API documentation:
http://struts.apache.org/2.1.2/struts2-core/apidocs/org/apache/struts2/interceptor/RequestAware.html
In order to implement this interface:
1) Your action class must declare that it implements the interface
2) Include the setter method (and optionally the getter) in your class:
public void setRequest(Map request) {
this.request = request;
}
public Map getRequest() {
return request;
}
3) Declare an instance request variable of type Map
Since the request is a Map, you use Map's put method to set request attributes.