Status error 404 (Servlet)

Asked

Viewed 63 times

0

I’m having a problem with this Servlet, when I start with Tomcat error 404 appears and displays the following message "The requested Resource [/test/Novaempresa] is not available".

JSP

<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
    pageEncoding="ISO-8859-1"%>
<!DOCTYPE html>
<html>
<head>
<meta charset="ISO-8859-1">
<title>Insert title here</title>
</head>
<body>
    <form method="post" action="NovaEmpresa">
        <label>Nome da empresa:</label>
        <input type="text" name="nome"/>
        <button type="submit">Enviar</button>
    </form>
</body>
</html>

Servlet

package teste;

import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

@WebServlet("/NovaEmpresa")
public class NovaEmpresa extends HttpServlet{
    protected void service(HttpServletRequest request, HttpServletResponse response) {
        System.out.println("teste!!!!");
    }
}
  • Very common mistake, could be several possibilities. I was going to ask for more details (Tomcat version, folder structure, configuration file) but maybe this can serve as a canonical question for the problem. See (English): https://stackoverflow.com/q/15545950/2241463

  • When it starts the server, your IDE creates a log, puts the log there for us to see.

1 answer

0

From what I am seeing he is not finding the page you are requesting try to map this to your Servlet address, for example

@WebServlet("/teste/NovaEmpresa")
public class NovaEmpresa extends HttpServlet{
    protected void service(HttpServletRequest request, HttpServletResponse response) 
    {
        System.out.println("teste!!!!");
    }
}

Browser other questions tagged

You are not signed in. Login or sign up in order to post.