Bom dia!
Amigos, sou novato na área de desenvolvimento em Java e estou passando apuros.
Estou usando a apostila da ?Caelum desenvolvimento web fj21? e na parte de JSTL já estou preso a uns quatro dias.
O problema é o seguinte tenho uma classe DAO mas não consigo acessar meu metodo ListaClientes de jeito nenhum.
Obs: Já instalei o jstl.jar e o standard.jar na WEB-INF\lib.
Estou usando o Tomcat 6.0 e o Eclipise.
O erro é esse logo abaixo.
org.apache.jasper. JasperException: An
exception occurred processing JSP page /listagemdeclientes .jsp at line 17
14:
15:
16:
17:
18:
19:
20:
[color=darkred].
.
.[/color]
root cause
javax.el.PropertyNo tFoundException: Property 'listarClientes' not found on type br.com.syssintegra. dao.ClienteDAO
javax.el.BeanELReso lver$BeanPropert ies.get(BeanELRe solver.java: 193)
Essa é minha classe para lista os clientes:
Essa é a minha JSP:<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional/ /EN" "http://www.w3. org/TR/html4/ loose.dtd">
<%@ taglib uri="http://java. sun.com/jsp/ jstl/core" prefix="c" %>
<%@ page language="java" contentType= "text/html;
charset=ISO- 8859-1"
pageEncoding= "ISO-8859- 1"%>
<%@ page import="br.com. syssintegra. vo.ClienteVO" %>
<%@ page import="br.com. syssintegra. dao.ClienteDAO" %>
<html>
<head>
<meta http-equiv=" Content-Type" content="text/ html;
charset=ISO- 8859-1">
<title>Insert title here</title>
</head>
<body>
<jsp:useBean id="dao" class="br.com. syssintegra. dao.ClienteDAO" />
[color=darkblue]
<c:forEach var="cliente" items="${dao. listarClientes} ">
<c:out value="${cliente. nome}"></ c:out><br>
</c:forEach>
[/color]
</body>
</html>
package br.com.syssintegra.dao;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.List;
import br.com.syssintegra.util.Conexao;
import br.com.syssintegra.vo.ClienteVO;
public class ClienteDAO {
private Connection con = null;
public ClienteDAO() throws SQLException{
this.con = Conexao.getConnection();
}
public void inserirDados(ClienteVO cliente) throws SQLException{
String sql ="INSERT INTO CadClientes (CODCLIENTE,NOME) VALUES" +
"(?,?)";
PreparedStatement stmt=null;
try {
stmt = con.prepareStatement(sql);
//Preencher os valores
stmt.setInt(1, cliente.getCodigo());
stmt.setString(2,cliente.getNome());
stmt.execute();
} catch (Exception e) {
// TODO: handle exception
} finally{
stmt.close();
con.close();
}
}
public List<ClienteVO> listarClientes() throws SQLException{
String sql="SELECT * FROM CadClientes";
PreparedStatement stmt=null;
ArrayList<ClienteVO> listaClientes = new ArrayList<ClienteVO>();
try {
stmt = con.prepareStatement(sql);
ResultSet rs = stmt.executeQuery();
while(rs.next()){
ClienteVO cliente = new ClienteVO();
cliente.setCodigo(rs.getInt("codcliente"));
cliente.setNome(rs.getString("nome"));
listaClientes.add(cliente);
}
rs.close();
stmt.close();
} catch (Exception e) {
// TODO: handle exception
System.out.println(e.getMessage());
}finally{
con.close();
}
return listaClientes;
}
}
