In a java web application(Servlet application) a file named web.xml is known as deployment descriptor file. It is a xml file which describes the deployment details about a servlet and <web-app> is the root element for it. When a request comes, web server uses web.xml file to map the URL of the request to the specific code that handle the request.
Sample code of web.xml file:
How web.xml works
When a request comes it is matched with url pattern in servlet mapping attribute. In the above example all urls mapped with the servlet. You can specify a url pattern according to your need. When url matched with url pattern web server try to find the servlet name in servlet attributes same as in servlet mapping attribute. When match found control is goes to the associated servlet class.
Servlet example by extending HttpServlet class.
out.println("<h1>JAVA means SILAN TECHNOLOGY</h1>");