You have not configured your HelloWorld
servlet in Deployment Descriptor (web.xml) file.
Deployment Descriptor (web.xml) file :
A web application's deployment descriptor describes the classes, resources and configuration of the application and how the web server uses them to serve web requests. When the web server receives a request for the application, it uses the deployment descriptor to map the URL of the request to the code that ought to handle the request.
The deployment descriptor is a file named
web.xml
. It resides in the app's WAR under theWEB-INF/
directory. The file is an XML file whose root element is<web-app>
web.xml
defines mappings between URL paths and the servlets that handle requests with those paths. The web server uses this configuration to identify the servlet to handle a given request and call the class method that corresponds to the request method (e.g. thedoGet()
method for HTTP GET requests).To map a URL to a servlet, you declare the servlet with the
<servlet>
element, then define a mapping from a URL path to a servlet declaration with the<servlet-mapping>
element.The
<servlet>
element declares the servlet, including a name used to refer to the servlet by other elements in the file, the class to use for the servlet, and initialization parameters. You can declare multiple servlets using the same class with different initialization parameters. The name for each servlet must be unique across the deployment descriptor.
Your file should be
<web-app xmlns="http://java.sun.com/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd"
version="3.0" metadata-complete="true">
<servlet>
<servlet-name>HelloWorld</servlet-name>
<servlet-class>yourpakage.HelloWorld</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>HelloWorld</servlet-name>
<url-pattern>/HelloWorld</url-pattern>
</servlet-mapping>
</web-app>