I am unable to execute this hello world servlet I have tried everything it has taken more than 10 hours still I cannot solve this It would be really thankful of anyone who.
This is the html code
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>lifelongterror</title>
</head>
<body>
<header><h1>This is a java web project #1</h1></header>
<form action="subtract" method="get">
<input type="submit">Click to say hello world.<br>
</form>
</body>
</html>
import javax.servlet.annotation.*;
import java.io.*;
@WebServlet( name="subtract" ,urlPatterns={"/subtract"})
class Serv3 extends HttpServlet{
static final long serialVersionUID = 3535335;
public void doGet(HttpServletRequest req, HttpServletResponse res) {
try {
PrintWriter p = res.getWriter();
p.println("hello World");
}catch(IOException e) {e.printStackTrace();}
}}
I have placed the servlet class in src>main>java>package and the html file in webapp (By Default)
This is the deployment configuration in server
Still it is throwing a 404 error and showing this page
I have tried several things but this won't go I think everything is ok but I cannot understand why this error is coming out of nowhere.
Also it is not a browser problem I have tried this in eclipse internal browser Chrome and Microsoft edge still it is not working.
All answers would be valuable.