Struts 2, Action, request e response

Ecco come avere a disposizione in struts 2 gli oggetti request e response in una action:

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import com.opensymphony.xwork2.ActionSupport;
import org.apache.struts2.interceptor.ServletRequestAware;
import org.apache.struts2.interceptor.ServletResponseAware;
public class MyAction extends ActionSupport implements 
  private HttpServletRequest request;
  private HttpServletResponse response;
  public String execute() throws Exception{
    return SUCCESS;
  public void setServletRequest(HttpServletRequest request){
    this.request = request;
  public HttpServletRequest getServletRequest(){
    return request;
  public void setServletResponse(HttpServletResponse response){
    this.response = response;
  public HttpServletResponse getServletResponse(){
    return response;

Leave a Reply

Your email address will not be published.

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>