0
I’m getting error 500 when trying to map Servlet, I don’t know what can be, I think it’s the class Servlet is wrong.
Servlet
public class addContatoServlet3 extends HttpServlet {
protected void doGet(HttpServletRequest request, HttpServletResponse response)
throws ServletException{
RequestDispatcher rd;
rd = request.getRequestDispatcher("/WEB-INF/View/adiciona-contato.jsp");
System.out.println("testando POST");
try{
rd.forward(request, response);
}catch(Exception e) {
e.printStackTrace();
}
}
protected void doPost(HttpServletRequest request,
HttpServletResponse response)
throws IOException, ServletException {
System.out.println("TESTANDO GET");
}
}
Web XML
<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://xmlns.jcp.org/xml/ns/javaee" xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-app_3_1.xsd" version="3.1">
<display-name>testeWeb</display-name>
<welcome-file-list>
<welcome-file>index.html</welcome-file>
<welcome-file>index.htm</welcome-file>
<welcome-file>index.jsp</welcome-file>
<welcome-file>default.html</welcome-file>
<welcome-file>default.htm</welcome-file>
<welcome-file>default.jsp</welcome-file>
</welcome-file-list>
<servlet>
<servlet-name>addContatoServlet3</servlet-name>
<servlet-class>src.controllers.addContatoServlet3</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>addContatoServlet3</servlet-name>
<url-pattern>/testando</url-pattern>
</servlet-mapping>
</web-app>
Edit: Eclipse even lists everything in my Servlets mapping:
Hi Viktor, thanks for the reply, but I still have the error "HTTP Status 500 - Error instantiating Servlet class controllers.addContact" :(
– user94991
Hello, in this case you have to post the error completely.
– Viktor Hugo