title: How to display in JSP a list obtained from Hibernate query
body: <p>I am creating an struts hibernate application. I have obtained a list using hibernate query and passed it in action class. But I don't know how to display it in JSP.</p>
  
  <p>I have successfully getting the list on the basis of query.
  Now I want to display this list in JSP.</p>
  
  <p>I have posted <code>struts.xml</code> and the JSP for showing result also.
  Kindly check. But in JSP nothing is showing up.
  I am using <code>s:iterate</code> to show the list. But no luck.
  Even I have tried printing simple text under <code>s:iterate</code>, just for testing.
  But it is also not showing up. </p>
  
  <p><strong>POJO class:</strong></p>
  
  <pre><code>package org.sachin.Model;
  
  import java.sql.Date;
  
  import javax.persistence.Entity;
  import javax.persistence.GeneratedValue;
  import javax.persistence.GenerationType;
  import javax.persistence.Id;
  import javax.persistence.Table;
  import javax.persistence.Temporal;
  
  @Entity
  @Table(name="feed")
  public class FeedBack {
  
  private FeedBack feedback;
   private int taste;
   private int waiter;
   private int infra;
   private int price;
  
   private int id;
  
   private Date date=new java.sql.Date(new java.util.Date().getTime());
  public int getTaste() {
      return taste;
  }
  public void setTaste(int taste) {
      this.taste = taste;
  }
  public int getWaiter() {
      return waiter;
  }
  public void setWaiter(int waiter) {
      this.waiter = waiter;
  }
  public int getInfra() {
      return infra;
  }
  public void setInfra(int infra) {
      this.infra = infra;
  }
  public int getPrice() {
      return price;
  }
  public void setPrice(int price) {
      this.price = price;
  }
  @Id
  @GeneratedValue(strategy=GenerationType.AUTO)
  public int getId() {
      return id;
  }
  public void setId(int id) {
      this.id = id;
  }
  
  
  @Temporal(javax.persistence.TemporalType.DATE)
  public Date getDate() {
      return date;
  }
  public void setDate(Date date) {
      this.date = date;
  }
  public FeedBack getFeedback() {
      return feedback;
  }
  public void setFeedback(FeedBack feedback) {
      this.feedback = feedback;
  }
  
  
  }
  </code></pre>
  
  <p><strong>Action Class:</strong></p>
  
  <pre><code>package org.sachin.action;
  
  import java.util.ArrayList;
  import java.util.List;
  import java.util.Map;
  
  import org.sachin.Model.Datepicker;
  import org.sachin.Model.FeedBack;
  import org.sachin.hibernate.DateSpecific;
  
  import com.opensymphony.xwork2.ActionContext;
  import com.opensymphony.xwork2.ActionSupport;
  
  public class SelectDateAction extends ActionSupport {
  
      /**
       * 
       */
  private static final long serialVersionUID = -8922465133057293868L;
  private Datepicker datepicker;
  private List&lt;FeedBack&gt; list =new ArrayList&lt;&gt;();;
  
      public List&lt;FeedBack&gt; getList() {
      return list;
  }
  public void setList(List&lt;FeedBack&gt; list) {
      this.list = list;
  }
      public String execute(){
  
          String date=getDatepicker().getDate1();
  
  
          DateSpecific da=new DateSpecific();
  
           list=da.find(date);
           for(FeedBack feed:list){
               System.out.println("price");
               System.out.println(feed.getPrice());
  
  
           }
  
          System.out.println("hi"+date);
  
          return SUCCESS;
      }
  
  
      public Datepicker getDatepicker() {
          return datepicker;
      }
      public void setDatepicker(Datepicker datepicker) {
          this.datepicker = datepicker;
      }
  
  }
  </code></pre>
  
  <p><strong>Hibernate class:</strong></p>
  
  <pre><code>public List&lt;FeedBack&gt; find(String Date) {
  
  
                  //  Transaction t=session.beginTransaction(); 
  
              String SQL_QUERY = " from FeedBack where date='"+Date+"'";
              System.out.println("i am in hiber");
              System.out.println(SQL_QUERY);
              org.hibernate.Query query = session.createQuery(SQL_QUERY);
              List&lt;FeedBack&gt; list = query.list();
            for(FeedBack f:list){
                System.out.println("price");
                System.out.println(f.getPrice());
            }
              return list;
  
          }
  </code></pre>
  
  <p>This is my <code>struts.xml</code> in which all actions are defined.For now the action is <code>ByDate</code>.</p>
  
  <p><strong><code>struts.xml</code>:</strong>        </p>
  
  <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
  &lt;!DOCTYPE struts PUBLIC
     "-//Apache Software Foundation//DTD Struts Configuration 2.0//EN"
     "http://struts.apache.org/dtds/struts-2.0.dtd"&gt;
  &lt;struts&gt;
  
      &lt;constant name="struts.devMode" value="true" /&gt;
  &lt;!--    &lt;constant name="struts.action.excludePattern" value="/ServletToExcludeFromStruts*" /&gt;
   --&gt;
      &lt;include file="login.xml"&gt;&lt;/include&gt;
      &lt;include file="AdminLogin.xml"&gt;&lt;/include&gt;
      &lt;include file="Feedback.xml"&gt;&lt;/include&gt;
      &lt;include file="NewUser.xml"&gt;&lt;/include&gt;
      &lt;include file="feedback.xml"&gt;&lt;/include&gt;
      &lt;include file="expression.xml"&gt;&lt;/include&gt;
      &lt;include file="logout.xml"&gt;&lt;/include&gt;
  
      &lt;package name="helloworld" namespace="/tut" extends="struts-default"&gt;
          &lt;action name="add" class="org.sachin.action.EditAdminAction"
              method="execute"&gt;
              &lt;result name="success"&gt;/JSP/success.jsp&lt;/result&gt;
              &lt;result name="error"&gt;/JSP/AdminUserNameExists.jsp&lt;/result&gt;
  
          &lt;/action&gt;
  
      &lt;/package&gt;
  
       &lt;package name="serve" namespace="/tut" extends="struts-default"&gt;
  
          &lt;action name="ByDate" class="org.sachin.action.SelectDateAction"
              method="execute"&gt;
              &lt;result name="success" type="redirect"&gt;/JSP/iterate.jsp&lt;/result&gt;
              &lt;result name="error" type="redirect"&gt;/JSP/FeedBack.jsp&lt;/result&gt;
              &lt;result name="input" type="redirect"&gt;/JSP/Rateus.jsp&lt;/result&gt;
  
          &lt;/action&gt;
      &lt;/package&gt;
  
  
  &lt;/struts&gt;
  </code></pre>
  
  <p>This is my JSP for showing list        </p>
  
  <p><strong><code>iterate.jsp</code>:</strong></p>
  
  <pre><code>&lt;%@ page language="java" contentType="text/html; charset=ISO-8859-1"
      pageEncoding="ISO-8859-1"%&gt;
  &lt;%@ taglib prefix="s" uri="/struts-tags" %&gt;
  
  &lt;!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"&gt;
  &lt;html&gt;
  &lt;s:form&gt;
  &lt;body&gt;
   &lt;h1&gt;Struts 2 Iterator tag example&lt;/h1&gt;
  
  &lt;h3&gt;Simple Iterator&lt;/h3&gt;
  &lt;ol&gt;
  &lt;s:iterator value="list"&gt;
   HE&lt;li&gt;&lt;s:property /&gt;&lt;/li&gt;
  &lt;/s:iterator&gt;
  &lt;/ol&gt;
    &lt;/body&gt;
    &lt;/s:form&gt;
    &lt;/html&gt;
  </code></pre>
  
  <p>I have successfully getting the list on the basis of query.
  Now I want to display this list in JSP.</p>