-1

this is project structure of th app as you can see i have created 2 servlet one is helloservlet and other is myservlet

it seems that application cannot detect the servlets i have created and rendering the default index.jsp

@WebServlet(name = "helloServlet", value = "/hello-servlet")
public class HelloServlet extends HttpServlet {
    private String message;

    public void init() {
        message = "Hello Michael!";
    }

    public void doGet(HttpServletRequest request, HttpServletResponse response) throws IOException {
        response.setContentType("text/html");

        // Hello
        PrintWriter out = response.getWriter();
        out.println("<html><body>");
        out.println("<h1>" + message + "</h1>");
        out.println("</body></html>");
    }

    public void destroy() {
    }
}
MAK
  • 59
  • 1
  • 6

2 Answers2

0

I used tomcat latest version and it working

Dr Mido
  • 2,414
  • 4
  • 32
  • 72
MAK
  • 59
  • 1
  • 6
0

Had the same problem on Tomcat 9. Couldn't open default servlet (/helloServlet) right after setting up the project.

Installed Tomcat 10 - problem solved.

I worked with java 17, intelliJ Ultimate 2022.3.2