Desculpe o incomodo.
Eu fiz uma select para trazer os dados relacionados entre tabelas
assim :
select aluno.*, curso.nome as cnome from Aluno as aluno inner join AlunoXCurso as c on aluno.CodAluno = c.CodAluno inner join Curso as curso on curso.CodCurso = c.CodCurso where aluno.login = ? and senha = ?
e eu jogo eles em uma list :
try {
conn = ConnectionManager.getConexao();
stmt = conn.prepareStatement("select aluno.*, curso.nome as cnome from Aluno as aluno inner join AlunoXCurso as c on "
+"aluno.CodAluno = c.CodAluno inner join Curso as curso on curso.CodCurso = c.CodCurso where aluno.login = ? and senha = ?");
stmt.setString(1, obj.getLogin());
stmt.setString(2, obj.getSenha());
rs = stmt.executeQuery();
while (rs.next()) {
Aluno aluno = new Aluno();
aluno.setCodAluno(rs.getInt("CodAluno"));
aluno.setRA(rs.getString("RA"));
aluno.setNome(rs.getString("Nome"));
aluno.setRG(rs.getString("RG"));
aluno.setCPF(rs.getString("CPF"));
aluno.setDataNascimento(rs.getDate("DataNascimento").toString());
aluno.setRua(rs.getString("Rua"));
aluno.setNumero(rs.getInt("Numero"));
aluno.setBairro(rs.getString("Bairro"));
aluno.setCidade(rs.getString("Cidade"));
aluno.setComplemento(rs.getString("Complemento"));
aluno.setTelefone(rs.getString("Telefone"));
aluno.setEmail(rs.getString("Email"));
aluno.setLogin(rs.getString("Login"));
aluno.setSenha(rs.getString("Senha"));
aluno.setCurso(rs.getString("cnome"));
lista.add(aluno);
}
} catch (SQLException e) {
throw new Exception("Erro ao deletar Aluno!", e);
} finally {
ConnectionManager.closeAll(conn, stmt, rs);
}
<c:forEach var="aluno" items="${aluno}">
<tr>
<tr>
<td>${aluno.RA}</td>
<td>${aluno.nome} </td>
<td>${aluno.RG}</td>
<td>${aluno.CPF}</td>
<td>${aluno.dataNascimento}</td>
<td>${aluno.rua} </td>
<td>${aluno.numero} </td>
<td>${aluno.bairro}</td>
<td>${aluno.cidade} </td>
<td>${aluno.complemento} </td>
<td>${aluno.telefone}</td>
<td>${aluno.email}</td>
<td>${aluno.login} </td>
<td>${aluno.senha}</td>
<td>${aluno.curso}</td>
</tr>
</c:forEach>
Eu queria saber como eu posso mostrar apenas uma vez os dados de aluno, e mostrar todos os cursos relacionados a ele, sem os dados do aluno se repetir.
Alguem poderia me ajudar por favor? muito obrigado