Solucionado (ver solução)
Solucionado
(ver solução)
1
resposta

listaEmpresas

HTTP Status 500 – Internal Server Error Type Exception Report

Message An exception occurred processing [/listaEmpresas.jsp] at line [15]

Description The server encountered an unexpected condition that prevented it from fulfilling the request.

Exception

org.apache.jasper.JasperException: An exception occurred processing [/listaEmpresas.jsp] at line [15]

12:

  • 13: <% 14: List lista = (List)request.getAttribute("empresas"); 15: for (Empresa empresa : lista) { 16: %> 17:
  • <%= empresa.getNome() %>
  • 18: <%

    Stacktrace: org.apache.jasper.servlet.JspServletWrapper.handleJspException(JspServletWrapper.java:626) org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:515) org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:385) org.apache.jasper.servlet.JspServlet.service(JspServlet.java:329) javax.servlet.http.HttpServlet.service(HttpServlet.java:733) org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:53) be.com.alura.gerenciador.servlet.ListaEmpresasServlet.doGet(ListaEmpresasServlet.java:28) javax.servlet.http.HttpServlet.service(HttpServlet.java:626) javax.servlet.http.HttpServlet.service(HttpServlet.java:733) org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:53) Root Cause

    java.lang.NullPointerException org.apache.jsp.listaEmpresas_jsp.jspService(listaEmpresasjsp.java:134) org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:71) javax.servlet.http.HttpServlet.service(HttpServlet.java:733) org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:477) org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:385) org.apache.jasper.servlet.JspServlet.service(JspServlet.java:329) javax.servlet.http.HttpServlet.service(HttpServlet.java:733) org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:53) be.com.alura.gerenciador.servlet.ListaEmpresasServlet.doGet(ListaEmpresasServlet.java:28) javax.servlet.http.HttpServlet.service(HttpServlet.java:626) javax.servlet.http.HttpServlet.service(HttpServlet.java:733) org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:53) Note A pilha de erros completa da causa principal está disponível nos logs do servidor.

1 resposta
solução!

consegui resolver package be.com.alura.gerenciador.servlet;

import java.io.IOException; 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;

@WebServlet("/listaEmpresas") 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);//eu tinha colocado ("empresa", lista);

    RequestDispatcher rd = request.getRequestDispatcher("/listaEmpresas.jsp");
    rd.forward(request, response);


}

}