title: How to iterate request attribute in struts 2?
body: <p>I'm trying to iterate request attribute from <code>ActionSupport</code> in JSP page name <code>EnergyConsumptionAnalysis</code> on page load to display it on browser using struts2 using same JSP page, but at runtime I'm getting empty display. Could anyone please tell me what's wrong I'm doing?</p>
  
  <p>JSP:</p>
  
  <pre><code>&lt;s:action name = "FetchSite"&gt;&lt;/s:action&gt;
    &lt;s:iterator value="siteData"&gt;
          &lt;s:property value = "name"/&gt;
    &lt;/s:iterator&gt;
  </code></pre>
  
  <p>Action support:</p>
  
  <pre><code>public class EnergyAction extends ActionSupport implements  ServletRequestAware
  {
      private HttpServletRequest request;
      @Override
      public String execute()
              throws Exception {
          //Get the site Data
          EnergyAnalysisBusinessHandler handler = new EnergyAnalysisBusinessHandler();
  
          //setting attribute as arraylist type
          request.setAttribute("siteData", handler.getSiteData());
          return SUCCESS;
     }
  
      public void setServletRequest(HttpServletRequest request){
          this.request = request;
      }
  
      public HttpServletRequest getServletRequest(){
      return request;
    }
  </code></pre>
  
  <p>struts.xml:</p>
  
  <pre><code>&lt;action name = "FetchSite" class = "com.javaworld.email.EnergyAction"&gt;
                 &lt;result name = "success"&gt;jsp/EnergyConsumptionAnalysis.jsp
                 &lt;/result&gt;
   &lt;/action&gt;
  </code></pre>