I'm implementing a WEB application with J2EE, but I'm not able to list the data coming from the ServletListCourses to the Liste.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();
}
}
}
The ServletListCourses sends the list of courses ("collection") to CourseList.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 can not list the DB values through the ServletListCourses, using JSTL.