O erro que aparece quando eu acesso a página busca é:
HTTP Status 500 - An exception occurred processing JSP page /WEB-INF/paginas/buscaempresa.jsp at line 20
type Exception report
message An exception occurred processing JSP page /WEB-INF/paginas/buscaempresa.jsp at line 20
description The server encountered an internal error that prevented it from fulfilling this request.
exception
org.apache.jasper.JasperException: An exception occurred processing JSP page /WEB-INF/paginas/buscaempresa.jsp at line 20
17: Resultado da busca:
18: <ul>
19: <c:forEach var="empresa" items="${empresas}">
20: <li>${empresas.id} ${empresas.nome} </li>}
21: </c:forEach>
22: </ul>
23: </body>
Stacktrace:
org.apache.jasper.servlet.JspServletWrapper.handleJspException(JspServletWrapper.java:574)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:476)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:396)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:340)
javax.servlet.http.HttpServlet.service(HttpServlet.java:729)
org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
org.netbeans.modules.web.monitor.server.MonitorFilter.doFilter(MonitorFilter.java:393)
br.com.alura.gerenciador.BuscaEmpresa.doGet(BuscaEmpresa.java:58)
javax.servlet.http.HttpServlet.service(HttpServlet.java:622)
javax.servlet.http.HttpServlet.service(HttpServlet.java:729)
org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
org.netbeans.modules.web.monitor.server.MonitorFilter.doFilter(MonitorFilter.java:393)
br.com.alura.gerenciador.FiltroDeAuditoria.doFilter(FiltroDeAuditoria.java:65)
root cause
javax.el.PropertyNotFoundException: Property 'id' not found on type java.util.HashMap$Values
javax.el.BeanELResolver$BeanProperties.get(BeanELResolver.java:268)
javax.el.BeanELResolver$BeanProperties.access$300(BeanELResolver.java:221)
javax.el.BeanELResolver.property(BeanELResolver.java:355)
javax.el.BeanELResolver.getValue(BeanELResolver.java:95)
org.apache.jasper.el.JasperELResolver.getValue(JasperELResolver.java:110)
org.apache.el.parser.AstValue.getValue(AstValue.java:169)
org.apache.el.ValueExpressionImpl.getValue(ValueExpressionImpl.java:184)
org.apache.jasper.runtime.PageContextImpl.proprietaryEvaluate(PageContextImpl.java:943)
org.apache.jsp.WEB_002dINF.paginas.buscaempresa_jsp._jspx_meth_c_005fforEach_005f0(buscaempresa_jsp.java:178)
org.apache.jsp.WEB_002dINF.paginas.buscaempresa_jsp._jspService(buscaempresa_jsp.java:134)
org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
javax.servlet.http.HttpServlet.service(HttpServlet.java:729)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:438)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:396)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:340)
javax.servlet.http.HttpServlet.service(HttpServlet.java:729)
org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
org.netbeans.modules.web.monitor.server.MonitorFilter.doFilter(MonitorFilter.java:393)
br.com.alura.gerenciador.BuscaEmpresa.doGet(BuscaEmpresa.java:58)
javax.servlet.http.HttpServlet.service(HttpServlet.java:622)
javax.servlet.http.HttpServlet.service(HttpServlet.java:729)
org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
org.netbeans.modules.web.monitor.server.MonitorFilter.doFilter(MonitorFilter.java:393)
br.com.alura.gerenciador.FiltroDeAuditoria.doFilter(FiltroDeAuditoria.java:65)
note The full stack trace of the root cause is available in the Apache Tomcat/8.0.27 logs.
Meu método doGet do buscaEmpresa.java é:
@Override
protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
String filtro = req.getParameter("filtro"); //Filtro vai receber o parametro dado na url ex www....../busca?filtro=fodase
Collection<Empresa> empresas = new EmpresaDAO().buscaPorSimilaridade(filtro); //simulador de um BD com várias empresas
req.setAttribute("empresas", empresas);
RequestDispatcher dispatcher = req.getRequestDispatcher("WEB-INF/paginas/buscaempresa.jsp");
dispatcher.forward(req, resp);
e minha página buscaempresa.jps é:
<%--
Document : buscaempresa
Created on : 12/05/2017, 13:39:08
Author : bruno
--%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>JSP Page</title>
</head>
<body>
Resultado da busca:
<ul>
<c:forEach var="empresa" items="${empresas}">
<li>${empresas.id} ${empresas.nome} </li>}
</c:forEach>
</ul>
</body>
</html>