Answer the question
In order to leave comments, you need to log in
Tomcat gives 404, how to make servlet work?
In idea, I created a new project "web application" called JEE Tutorial. web.xml was generated automatically
<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns="http://xmlns.jcp.org/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-app_3_1.xsd"
version="3.1">
</web-app>
import ....
@WebServlet(name = "ServletExample", urlPatterns = "/test")
public class ServletExample extends HttpServlet {
protected void service(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
PrintWriter out = response.getWriter();
out.println("Hello Servlet!");
}
}
Answer the question
In order to leave comments, you need to log in
Add to your Web.xml
<servlet>
<servlet-name>*Имя сервлета*</servlet-name>
<servlet-class>*Путь к сервлету(package)*</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>*Имя сервлета*</servlet-name>
<url-pattern>*Маппинг сервлета*</url-pattern>
</servlet-mapping>
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question