Alguem poderia me ajudar!!!.. estou tentando usar o eclipse para aplicações web porém quando execulto o código abaixo está me dando o seguinte erro…
type Exception report
message
description The server encountered an internal error () that prevented it from fulfilling this request.
exception
org.apache.jasper.JasperException: Unable to compile class for JSP
An error occurred at line: 5 in the jsp file: /lista-scriptlet.jsp
Generated servlet error:
Contato cannot be resolved to a type
An error occurred at line: 5 in the jsp file: /lista-scriptlet.jsp
Generated servlet error:
Contato cannot be resolved to a type
<%@ page import=“java.util.,br.com.locadora.jdbc.,br.com.locadora.jdbc.dao.,br.com.jdbc.contato.”%>
-
<%
Contato contato = new Contato();
ContatoDAO dao = new ContatoDAO();
List contatos = dao.getLista();
for (int i = 0; i< contatos.size(); i++){
contato = contatos.get(i);
%>
- <%=contato.getNome()%>,<%= contato.getEmail()%>: <%= contato.getEndereco()%> <% } %>
package br.com.locadora.jdbc.dao;
public class ContatoDAO {
private Connection con;
public ContatoDAO() throws SQLException {
this.con = ConnectionFactory.getConnection();
}
public void adciona(Contato contato) throws SQLException {
PreparedStatement stmt = this.con
.prepareStatement(“insert into contatos(nome,email,endereco) values (?,?,?)”);
stmt.setString(1, contato.getNome());
stmt.setString(2, contato.getEmail());
stmt.setString(3, contato.getEndereco());
stmt.execute();
stmt.close();
}
public List getLista() throws SQLException {
PreparedStatement stmt = this.con
.prepareStatement(“select * from contatos”);
ResultSet result = stmt.executeQuery();
List list = new ArrayList();
while (result.next()) {
Contato contato = new Contato();
contato.setId(result.getLong(“id”));
contato.setNome(result.getString(“nome”));
contato.setEmail(result.getString(“email”));
contato.setEndereco(result.getString(“endereco”));
list.add(contato);
}
result.close();
stmt.close();
return list;
}
public void altera(Contato contato) throws SQLException {
PreparedStatement stmt = this.con
.prepareStatement(“update contatos set nome=?, email=?, endereco=? where id=?”);
stmt.setString(1, contato.getNome());
stmt.setString(2, contato.getEmail());
stmt.setString(3, contato.getEndereco());
stmt.setLong(4, contato.getId());
System.out.println(“Alterado com sucesso!!!”);
stmt.execute();
stmt.close();
}
public Contato busca(long id) throws SQLException {
PreparedStatement stmt = this.con
.prepareStatement(“select * from contatos where id=?”);
stmt.setLong(1,id);
ResultSet result = stmt.executeQuery();
boolean existe = result.next();
if (existe) {
String nome = result.getString(“nome”);
String email = result.getString(“email”);
String endereco = result.getString(“endereco”);
Contato contato1 = new Contato();
contato1.setNome(nome);
contato1.setEmail(email);
contato1.setEndereco(endereco);
result.close();
stmt.close();
return contato1;
}else{
result.close();
return null;
}
}
public void deleta(Contato contato) throws SQLException {
PreparedStatement stmt = this.con
.prepareStatement(“delete from contatos where id=?”);
stmt.setLong(1, contato.getId());
System.out.println(“exclusão com sucesso!!!”);
stmt.execute();
stmt.close();
}