0

I am writing a simple servlet, as below

@WebServlet("/helloServlet")
public class HelloServlet extends HttpServlet {
    private static final long serialVersionUID = 1L;
       
    public HelloServlet() {
        super();
       
    }

    
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        String yourName = request.getParameter("yourName");
        PrintWriter writer = response.getWriter();
        writer.println("<h1>Hello " + yourName + "</h1>");
        writer.close();
    }
}

And below is my JSP

<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Hello World Java EE</title>
</head>
<body>
   <h1>Hello JSP and Servlet!</h1>
<form action="helloServlet" method="post">
    Enter your name: <input type="text" name="yourName" size="20">
    <input type="submit" value="Call Servlet" />
</form>
</body>
</html>

But I see

enter image description here

Saurabh Jhunjhunwala
  • 2,832
  • 3
  • 29
  • 57
  • Are you sure that it is sucessfully deployed as `HelloWorldJavaEE` ? Check your logs, check your `webapps` dir – Scary Wombat Apr 27 '21 at 08:25
  • Refer this:https://stackoverflow.com/questions/11731377/servlet-returns-http-status-404-the-requested-resource-servlet-is-not-availa – naveen4181 Apr 27 '21 at 08:32

0 Answers0