package br.com.alura.gerenciador.servlet;
import java.io.IOException;
import java.io.PrintWriter;
import java.util.List;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
@WebServlet("/listaEmpresas")
public class ListaEmpresaServlet extends HttpServlet {
private static final long serialVersionUID = 1L;
public ListaEmpresaServlet() {
super();
}
protected void doGet(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
Banco banco = new Banco();
List<Empresa> lista = banco.getEmpresas();
PrintWriter out = response.getWriter();
out.println("<html><body>");
out.println("<ul>");
for (Empresa empresa : lista) {
out.println("<li>" + empresa.getNome() + "</li>");
}
out.println("<ul>");
out.println("</html></body>");
}
}
<%@ 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 Standart Taglib</title>
</head>
<body>
Lista de empresas: <br />
<ul>
<c:forEach items="${empresas}" var="empresa">
<li>${empresa.nome} - <fmt:formatDate value="${empresa.dataAbertura }" pattern="dd/MM/yyyy"/></li>
</c:forEach>
</ul>
<ul>
</body>
</html>
não aparece as datas de criação das empresas