<%@page import="java.text.SimpleDateFormat"%>
<%@page import="br.aiec.Pessoa"%>
<%@page import="java.util.List"%>
<%@page language="java"
contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Histórico de Visitantes - JSP</title>
</head>
<body>
<%
//Obtendo a lista de histórico do contexto da aplicação
List<Pessoa> listHistorico = (List<Pessoa>)getServletContext().getAttribute("historyVisits");
//Criando um objeto para formatar a data
SimpleDateFormat dateFormat = new SimpleDateFormat("dd/MM/yyyy");
%>
<table border="1">
<thead>
<tr>
<td>Nome</td>
<td>Data Nascimento</td>
<td>Idade</td>
</tr>
</thead>
<tbody>
<%--Esse laço percorre a lista de visitantes, exibindo cada um deles --%>
<% for(int i = 0; i < listHistorico.size(); i++){ %>
<% Pessoa pessoa = listHistorico.get(i); %>
<tr>
<td><%=pessoa.getNome()%></td>
<td><%=dateFormat.format(pessoa.getDataNascimento())%></td>
<td><%=pessoa.getIdade()%></td>
</tr>
<% } %>
</tbody>
</table>
</body>
</html>