Boa tarde, estou realizando um projeto da faculdade, porém não estou conseguindo exito.
Consiste em um trabalho de pediatria.
Esse eh o erro
[quote]HTTP Status 500 -
type Exception report
message
descriptionThe server encountered an internal error () that prevented it from fulfilling this request.
exception
javax.servlet.ServletException: PWC1397: Wrapper cannot find servlet class Servlet.PacienteServlet or a class it depends on
root cause
java.lang.ClassNotFoundException: Servlet.PacienteServlet
note The full stack traces of the exception and its root causes are available in the GlassFish Server Open Source Edition 3.0.1 logs.
GlassFish Server Open Source Edition 3.0.1[/quote]
A parte de listar
[code]<html>
<head>
<meta http-equiv=“Content-Type” content=“text/html; charset=UTF-8”>
<title>LISTA</title>
</head>
<body>
<h2>LISTA</h2>
<a >Página Principal</a><br/>
<a >Incluir novo paciente</a><br/><br/>
<table border="1" cellpadding="2" cellspacing="0">
<tr>
<th>Nome</th>
<th>Telefone</th>
<th></th>
</tr>
<c:forEach var="lista" items="${ requestScope.pacientes }">
<tr>
<td><a >${lista.nome}</a></td>
<td>${lista.telefone}</td>
<td><a >Excluir</a></td>
</tr>
</c:forEach>
</table>
</body>
</body>
</html>
[/code]
a parte do Servlet
package servlet;
import java.io.*;
import java.sql.SQLException;
import java.util.List;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.servlet.*;
import javax.servlet.http.*;
import modelo.Paciente;
import modeloDAO.PacienteDAO;
public class PacienteServlet extends HttpServlet {
protected void processRequest(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException, SQLException {
response.setContentType("text/html;charset=UTF-8");
//Parametro acao
String acao = request.getParameter("acao");
RequestDispatcher rd = null;
if (acao.equals("principal")) {
rd = request.getRequestDispatcher("/Paciente.jsp");
} else {
//Objetos
Paciente p = new Paciente();
PacienteDAO pdao = new PacienteDAO();
//codigoPaciente
String codigoPaciente = request.getParameter("codigoPaciente");
if (codigoPaciente != null) {
p.setCodigoPaciente(Integer.parseInt(codigoPaciente));
}
//Telefone
String telefone = request.getParameter("telefone");
if (telefone != null) {
p.setTelefone(Integer.parseInt(telefone));
}
//Nome
p.setNome(request.getParameter("nome"));
//Demais ações
if (acao.equals("incluir")) {
pdao.incluirSimples(p);
rd = request.getRequestDispatcher("PacienteServlet?acao=listar");
} else if (acao.equals("alterar")) {
pdao.alterar(p);
rd = request.getRequestDispatcher("PacienteServlet?acao=listar");
} else if (acao.equals("excluir")) {
pdao.excluir(p.getCodigoPaciente());
rd = request.getRequestDispatcher("PacienteServlet?acao=listar");
} else if (acao.equals("consultar")) {
p = pdao.consultar(p.getCodigoPaciente());
HttpSession session = request.getSession();
session.setAttribute("paciente", p);
rd = request.getRequestDispatcher("/PacienteAlterar.jsp");
} else if (acao.equals("listar")) {
List pacientes = pdao.listarSimples();
request.setAttribute("pacientes", pacientes);
rd = request.getRequestDispatcher("/PacienteListar.jsp");
}
}
rd.forward(request, response);
}
@Override
protected void doGet(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
try {
processRequest(request, response);
} catch (SQLException ex) {
Logger.getLogger(PacienteServlet.class.getName()).log(Level.SEVERE, null, ex);
}
}
@Override
protected void doPost(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
try {
processRequest(request, response);
} catch (SQLException ex) {
Logger.getLogger(PacienteServlet.class.getName()).log(Level.SEVERE, null, ex);
}
}
@Override
public String getServletInfo() {
return "Short description";
}
}
Paciente DAO
package modeloDAO;
import geral.Conexao;
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 modelo.Convenio;
import modelo.Paciente;
public class PacienteDAO {
private Connection conexao;
public PacienteDAO() throws SQLException {
this.conexao = Conexao.getConexao();
}
public void incluirSimples(Paciente paciente) throws SQLException {
String sql = "insert into paciente(nome,telefone) values (?,?)";
PreparedStatement stmt = conexao.prepareStatement(sql);
stmt.setString(1, paciente.getNome());
stmt.setInt(2, paciente.getTelefone());
}
public void incluir(Paciente paciente) throws SQLException {
String sql = "insert into paciente(nome,sobrenome, dtNascimento,endereco,email,dtPrimeiraConsulta,telefone) values (upper(?),upper(?),?,upper(?),upper(?),?,?)";
// String sql = "insert into paciente(nome,telefone) values (upper(?),?)";
PreparedStatement stmt = conexao.prepareStatement(sql);
stmt.setString(1, paciente.getNome());
stmt.setString(2, paciente.getSobrenome());
stmt.setInt(3, paciente.getDataDeNascimento());
stmt.setString(4, paciente.getEndereco());
stmt.setString(5, paciente.getEmail());
stmt.setInt(6, paciente.getDataPrimeiraConsulta());
//stmt.setInt(7, paciente.getCpf());
//stmt.setInt(7, paciente.getCodigoPaciente());
stmt.setInt(7, paciente.getTelefone());
stmt.execute();
stmt.close();
}
public void alterar(Paciente paciente) throws SQLException {
String sql = "update paciente set nome=?, telefone=? where codigoPaciente=?";
PreparedStatement stmt = conexao.prepareStatement(sql);
stmt.setString(1, paciente.getNome());
stmt.setInt(2, paciente.getTelefone());
stmt.setInt(3, paciente.getCodigoPaciente());
stmt.execute();
stmt.close();
}
public Paciente consultar(int codigoPaciente) throws SQLException {
String sql = "select * from paciente where codigoPaciente=?";
PreparedStatement stmt = conexao.prepareStatement(sql);
stmt.setInt(1, codigoPaciente);
ResultSet rs = stmt.executeQuery();
Paciente f = new Paciente();
if (rs.next()) {
f.setCodigoPaciente(rs.getInt("codigoPaciente"));
f.setNome(rs.getString("nome"));
f.setTelefone(rs.getInt("telefone"));
}
rs.close();
stmt.close();
return f;
}
public Paciente consultarNome(String nome) throws SQLException {
String sql = "select * from paciente where upper(nome)=?";
PreparedStatement stmt = conexao.prepareStatement(sql);
stmt.setString(1, nome.toUpperCase());
ResultSet rs = stmt.executeQuery();
Paciente f = new Paciente();
if (rs.next()) {
f.setCodigoPaciente(rs.getInt("codigoPaciente"));
f.setNome(rs.getString("nome"));
f.setTelefone(rs.getInt("codigo"));
}
rs.close();
stmt.close();
return f;
}
public Paciente consultarSigla(String telefone) throws SQLException {
String sql = "select * from paciente where upper(telefone)=?";
PreparedStatement stmt = conexao.prepareStatement(sql);
stmt.setString(1, telefone.toUpperCase());
ResultSet rs = stmt.executeQuery();
Paciente f = new Paciente();
if (rs.next()) {
f.setCodigoPaciente(rs.getInt("codigoPaciente"));
f.setNome(rs.getString("nome"));
f.setTelefone(rs.getInt("codigo"));
}
rs.close();
stmt.close();
return f;
}
public Paciente consultarTelefone(int codigo) throws SQLException {
String sql = "select * from paciente where codigo=?";
PreparedStatement stmt = conexao.prepareStatement(sql);
stmt.setInt(1, codigo);
ResultSet rs = stmt.executeQuery();
Paciente f = new Paciente();
if (rs.next()) {
f.setCodigoPaciente(rs.getInt("codigoPaciente"));
f.setNome(rs.getString("nome"));
f.setTelefone(rs.getInt("codigo"));
}
rs.close();
stmt.close();
return f;
}
public List<Paciente> listarSimples() throws SQLException {
String sql = "select * from paciente";
PreparedStatement stmt = conexao.prepareStatement(sql);
ResultSet rs = stmt.executeQuery();
List<Paciente> pacientes = new ArrayList<Paciente>();
while (rs.next()) {
Paciente f = new Paciente();
f.setCodigoPaciente(rs.getInt("codigoPaciente"));
f.setNome(rs.getString("nome"));
f.setTelefone(rs.getInt("telefone"));
pacientes.add(f);
}
rs.close();
stmt.close();
return pacientes;
}
public List<Paciente> listar() throws SQLException {
String sql = "select * from paciente";
PreparedStatement stmt = conexao.prepareStatement(sql);
ResultSet rs = stmt.executeQuery();
List<Paciente> pacientes = new ArrayList<Paciente>();
Convenio conv = new Convenio();
while (rs.next()) {
Paciente f = new Paciente();
f.setCodigoPaciente(rs.getInt("codigoPaciente"));
f.setNome(rs.getString("nome"));
f.setSobrenome(rs.getString("sobrenome"));
f.setDataDeNascimento(rs.getInt("dtNascimento"));
f.setEndereco(rs.getString("endereco"));
f.setEmail(rs.getString("email"));
f.setDataPrimeiraConsulta(rs.getInt("dtPrimeiraConsulta"));
conv.setCodigoConv(rs.getInt("codigoConv"));
f.setTelefone(rs.getInt("telefone"));
pacientes.add(f);
}
rs.close();
stmt.close();
return pacientes;
}
public void excluir(int codigoPaciente) throws SQLException {
String sql = "delete from paciente where codigoPaciente=?";
PreparedStatement stmt = conexao.prepareStatement(sql);
stmt.setInt(1, codigoPaciente);
stmt.execute();
stmt.close();
}
}
CLASSE PACIENTE
public class Paciente {
private int codigoPaciente;
private String nome;
private String sobrenome;
//
private String endereco;
private int telefone;
private String email;
private boolean conveniado;
private int dataDeNascimento;
private int dataPrimeiraConsulta;
private int cpf;
Convenio conv = new Convenio();
public Paciente() {
}
public Paciente(String nome, int telefone) {
this.nome = nome;
this.telefone = telefone;
}
}