Meu listEmpresa.jsp é apresentado em branco, sem as empresas cadastradas no banco.
Segue classes:
/**
* Classe lista empresa
*/
package br.com.alura.gerenciador.servlet;
import java.io.IOException;
import java.io.PrintWriter;
import java.util.List;
import javax.servlet.RequestDispatcher;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
/**
* Servlet implementation class ListaEmpresasServlet
*/
@WebServlet("/listEmpresa")
public class ListaEmpresasServlet extends HttpServlet {
private static final long serialVersionUID = 1L;
protected void doGet(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
Banco banco = new Banco();
List<Empresa> lista = banco.getEmpresas();
request.setAttribute("empresas", lista);
RequestDispatcher rd = request.getRequestDispatcher("/listEmpresa.jsp");
rd.forward(request, response);
}
/**
* @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)
*/
}
e
<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
pageEncoding="ISO-8859-1"%>
<%@ page import="java.util.List, br.com.alura.gerenciador.servlet.Empresa"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt" %>
<!DOCTYPE html>
<html>
<head>
<meta charset="ISO-8859-1">
<title>Java Standard Taglib</title>
</head>
<body>
Lista de empresas: <br />
<ul>
<c:forEach items="${empresas}" var="empresa">
<li>${empresa.nome } </li>
</c:forEach>
</ul>
</body>
</html>