4
I’m implementing a WEB application with J2EE, but I’m not able to list the data coming from Servletlistarcursos to the Listdecursos.jsp page that uses JSTL.
public class ServletListarCursos extends HttpServlet {
private static final long serialVersionUID=1L;
private static final String CONTENT_TYPE="text/html";
public void doPost(HttpServletRequest request, HttpServletResponse response)throws HTTPException, IOException{
response.setContentType(CONTENT_TYPE);
HttpSession session = request.getSession(true);
FachadaControladorDAO fachada = FachadaControladorDAO.getInstancia();
Curso curso = new Curso();
try {
List colecao = fachada.getListarCursos(curso);
session.setAttribute("colecao", colecao);
RequestDispatcher rd = request.getRequestDispatcher("view/curso/ListaDeCursos.jsp");
rd.forward(request, response);
} catch (RepositorioException ex) {
Logger.getLogger(ServletListarCursos.class.getName()).log(Level.SEVERE, null, ex);
}catch(ServletException ex){
ex.printStackTrace();
}
}
}
Servletlistarcursos send the course list("collection") to Listadecursos.jsp.
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<%@taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Lista de cursos</title>
<select id="selecaoCursos" name="selecaoCursos" >
<option value="0" >Selecione o curso</option>
<c:forEach items="${colecao}" var="cursos" >
<option value="${cursos.codigoCurso}"
id="codigoCurso">
${cursos.nomeCurso}
</option>
</c:forEach>
</select>
</body>
</html>
Doubt I’m not able to list the values of DB through Servletlistarcursos, using JSTL.
I see nothing wrong. is sure that your collection list is filling something?
– Marconi