Olá pessoal,
estou aprendendo JSTL com a apostila da Caelum, e to tendo problemas pra usar o forEach...
Eu consigo usar o
org.apache.jasper.JasperException: An exception occurred processing JSP page /jstlTeste.jsp at line 17
14:
15: <jsp:useBean id="dao" class="persistence.ContatoPostgreSQLDAO"></jsp:useBean>
16:
17: <c:forEach var="contato" items="${dao.lista}">
18: Nome: ${contato.nome}
19: </c:forEach>
20:
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
pageEncoding="ISO-8859-1"%>
<%@page import="persistence.ContatoPostgreSQLDAO"%>
<!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=ISO-8859-1">
<title>JSTL teste</title>
</head>
<body>
<jsp:useBean id="dao" class="persistence.ContatoPostgreSQLDAO"></jsp:useBean>
<c:forEach var="contato" items="${dao.lista}">
Nome: ${contato.nome}
</c:forEach>
</body>
</html>
public class ContatoPostgreSQLDAO implements ContatoDAO {
@Override
public ArrayList<Contato> getLista(String email) {
// TODO Auto-generated method stub
ArrayList<Contato> array = new ArrayList<Contato>();
Contato c1 = new Contato();
Contato c2 = new Contato();
Contato c3 = new Contato();
c1.setNome("aaa");
c1.setIdade("80");
c1.setTelefone("22222222");
c2.setNome("bbb");
c2.setIdade("90");
c2.setTelefone("95888888");
c3.setNome("ccc");
c3.setIdade("52");
c3.setTelefone("06591123");
array.add(c1);
array.add(c2);
array.add(c3);
return array;
}
}
O que está errado?