I am trying to display a list of cars from my jsp. But i don't understand why nothing appears at the runtime :
Servlet 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<Vehicle> list = gestion.getVehiclesAvailable(category,place,start,end);
HttpSession session=request.getSession();
session.setAttribute("list", list);
request.getRequestDispatcher("listeOfVehicle.jsp").forward(request,response);
}
}
JSP code:
<table border="1">
<thead>
<tr>
<th>Category</th>
<th>Brand</th>
<th>Model</th>
<th>Places</th>
</tr>
</thead>
<tbody>
<c:forEach var="vehicle" items="${list}">
<tr>
<td><c:out value="${vehicle.category}" /></td>
<td><c:out value="${vehicle.brand}" /></td>
<td><c:out value="${vehicle.model}" /></td>
<td><c:out value="${vehicle.places}" /></td>
</tr>
</c:forEach>
</tbody>
</table>
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.
I am using hibernate (which works fine and access the database perfectly) and using the MVC model.
Here is my form:
<body>
<Form action="DisplayCar" method="post">
<TABLE BORDER=0>
<TR>
<TD>Category</TD>
<TD>
<SELECT name="category">
<OPTION VALUE="1">1</OPTION>
<OPTION VALUE="2">2</OPTION>
<OPTION VALUE="3">3</OPTION>
<OPTION VALUE="4">4</OPTION>
<OPTION selected VALUE="5">5</OPTION>
</SELECT>
</TD>
</TR>
<TR>
<TD>Date</TD>
<TD>
<P>Starting date: <input type="text" name="dstart" />
<P>End date <input type="text" name="dend" />
</TD>
</TR>
<TR>
<TD>Place</TD>
<TD>
<SELECT name="place">
<OPTION VALUE="4">4</OPTION>
<OPTION VALUE="5">5</OPTION>
</SELECT>
</TD>
</TR>
<TR>
<TD COLSPAN=2>
<INPUT type="submit" value="Send">
</TD>
</TR>
</TABLE>
</Form>
</body>
</html>