2
respostas

HTTP Status [404] – [Not Found]

ao executar no Chrome a URL http://localhost:1013/gerenciador/listaEmpresas mostra a seguinte mensagem: Type Status Report

Message /gerenciador/listaEmpresas

Description The origin server did not find a current representation for the target resource or is not willing to disclose that one exists.

Apache Tomcat/9.0.0.M20

No console do Eclipse nostra o seguinte erro: At least one JAR was scanned for TLDs yet contained no TLDs. Enable debug logging for this logger for a complete list of JARs that were scanned but no TLDs were found in them. Skipping unneeded JARs during scanning can improve startup time and JSP compilation time.

Como resolver ?

ackage 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;

/**
 * Servlet implementation class ListaEmpresasServlet
 */
@WebServlet(name = "/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();

        PrintWriter out = response.getWriter();
        out.println("<html><body>");
        out.println("<ul>");
        for (Empresa empresa:lista) {
            out.println("<li>" + empresa.getName() + "</li>");
        }
        out.println("</ul>");
        out.println("</body></html>");
    }

}
2 respostas

Onde está @WebServlet(name = "/listaEmpresas") deixe como @WebServlet("/listaEmpresas") ou troque name por urlPatterns.

Desculpa a demora. Mas, consegui resolver. Valeu