I am totally new to writing servlets. I have created a simple HelloWorld program, but while running the application I'm getting the following error:
HTTP Status 404 - /HelloWorld/HelloWorld
type Status report
message /HelloWorld/HelloWorld
description: The requested resource is not available.
Below is my code:
import java.io.IOException;import java.io.PrintWriter;import javax.servlet.ServletException;import javax.servlet.annotation.WebServlet;import javax.servlet.http.HttpServlet;import javax.servlet.http.HttpServletRequest;import javax.servlet.http.HttpServletResponse;@WebServlet("/HelloWorld")public class HelloWorld extends HttpServlet { private static final long serialVersionUID = 1L; public HelloWorld() { super(); } protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { PrintWriter out=response.getWriter(); out.println("Hello World"); }}
And my web.xml
<display-name>HelloWorld</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></web-app>
I'm using Tomcat version:7.0 and my IDE is Eclipse Luna. Why is this error being thrown?