title: How to Display data from database with servlet/jsp
body: <p>I am trying to display a list of cars from my jsp. But i don't understand why nothing appears at the runtime :</p>
  
  <p>Servlet code: </p>
  
  <pre><code>public class SDisplayCar extends HttpServlet{
  private static final long serialVersionUID = 1L;
  private Gestion gestion = Gestion.getInstance();
  
  protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException
  {
      int category = Integer.parseInt(request.getParameter("category"));
      int place = Integer.parseInt(request.getParameter("place"));
      String startingDate = request.getParameter("dstart"); 
      String endingDate = request.getParameter("dend");
  
      Date start = gestion.getDate(startingDate);
      Date end =  gestion.getDate(endingDate);
  
      List&lt;Vehicle&gt; list = gestion.getVehiclesAvailable(category,place,start,end);
  
      HttpSession session=request.getSession();
      session.setAttribute("list", list);
  
      request.getRequestDispatcher("listeOfVehicle.jsp").forward(request,response);
  }
  }
  </code></pre>
  
  <p>JSP code:</p>
  
  <pre><code>&lt;table border="1"&gt;
              &lt;thead&gt;
                  &lt;tr&gt;
                      &lt;th&gt;Category&lt;/th&gt;
                      &lt;th&gt;Brand&lt;/th&gt;
                      &lt;th&gt;Model&lt;/th&gt;
                      &lt;th&gt;Places&lt;/th&gt;
                  &lt;/tr&gt;
              &lt;/thead&gt;
              &lt;tbody&gt;
                  &lt;c:forEach var="vehicle" items="${list}"&gt;
                  &lt;tr&gt;
                      &lt;td&gt;&lt;c:out value="${vehicle.category}"  /&gt;&lt;/td&gt;
                      &lt;td&gt;&lt;c:out value="${vehicle.brand}" /&gt;&lt;/td&gt;
                      &lt;td&gt;&lt;c:out value="${vehicle.model}" /&gt;&lt;/td&gt;
                      &lt;td&gt;&lt;c:out value="${vehicle.places}"  /&gt;&lt;/td&gt;
                  &lt;/tr&gt;
                  &lt;/c:forEach&gt;
              &lt;/tbody&gt;
          &lt;/table&gt;
  </code></pre>
  
  <p>Am I missing something. I don't get it. When I run the servlet it should display the list of vehicles in the jsp page.</p>
  
  <p>I am using hibernate (which works fine and access the database perfectly) and using the MVC model.</p>
  
  <p>Here is my form:</p>
  
  <pre><code>   &lt;body&gt;
  &lt;Form action="DisplayCar" method="post"&gt;
  &lt;TABLE BORDER=0&gt;
  &lt;TR&gt;
      &lt;TD&gt;Category&lt;/TD&gt;
      &lt;TD&gt;
      &lt;SELECT name="category"&gt;
          &lt;OPTION VALUE="1"&gt;1&lt;/OPTION&gt;
          &lt;OPTION VALUE="2"&gt;2&lt;/OPTION&gt;
          &lt;OPTION VALUE="3"&gt;3&lt;/OPTION&gt;
          &lt;OPTION VALUE="4"&gt;4&lt;/OPTION&gt;
          &lt;OPTION selected VALUE="5"&gt;5&lt;/OPTION&gt;
      &lt;/SELECT&gt;
      &lt;/TD&gt;
  &lt;/TR&gt;
  &lt;TR&gt;
      &lt;TD&gt;Date&lt;/TD&gt;
      &lt;TD&gt;
          &lt;P&gt;Starting date: &lt;input type="text" name="dstart" /&gt;
          &lt;P&gt;End date &lt;input type="text" name="dend" /&gt;
      &lt;/TD&gt;
  &lt;/TR&gt;
  &lt;TR&gt;
      &lt;TD&gt;Place&lt;/TD&gt;
      &lt;TD&gt;
      &lt;SELECT name="place"&gt;
          &lt;OPTION VALUE="4"&gt;4&lt;/OPTION&gt;
          &lt;OPTION VALUE="5"&gt;5&lt;/OPTION&gt;    
      &lt;/SELECT&gt;
      &lt;/TD&gt;
  &lt;/TR&gt;
  &lt;TR&gt;
      &lt;TD COLSPAN=2&gt;
      &lt;INPUT type="submit" value="Send"&gt;
      &lt;/TD&gt;
  &lt;/TR&gt;
  &lt;/TABLE&gt;
  &lt;/Form&gt; 
  &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>