Sunday, 18 August 2013

Can't make c:forEach and c:out works (I get a blank page)

Can't make c:forEach and c:out works (I get a blank page)

I create the follow JSP page to display a list of itens from a database,
but when I run the application in the container tomcat7, I get a blank
page:
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Lista de produtos</title>
</head>
<body>
<div id="display">
<table border=2>
<thead>
<tr>
<th>Model</th>
<th>Vendor</th>
<th>Price</th>
</tr>
</thead>
<tbody>
<c:forEach var="item" items="${list}">
<tr>
<td><c:out value="${item.model}"/></td>
<td><c:out value="${item.vendor}"/></td>
<td><c:out value="${item.price}"/></td>
</tr>
</c:forEach>
</tbody>
</table>
</div>
</body>
</html>
This page is triggered by the following method doGet from my servlet:
protected void doGet(HttpServletRequest request, HttpServletResponse
response) throws ServletException, IOException {
String parametro = request.getParameter("p");
List<equipment> lista = new ArrayList<equipment>();
if(parametro.equals("*")) {
try {
lista = FindAllItens();
} catch (ClassNotFoundException | SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
else {
try {
lista = FindItens(parametro);
} catch (ClassNotFoundException | SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
request.getSession().setAttribute("list", lista);
request.getRequestDispatcher("display.jsp").forward(request, response);
}
Someone have an idea what may be missing for make the page works?

No comments:

Post a Comment