Adding the Servlet to the web.xml file
Each servlet must appear in a web.xml file within a context directory. To add a servlet to an existing context, add a servlet and servlet-mapping element to the context. The sample below shows a complete web.xml file for the HelloWorldExample servlet:
The deployment descriptor above creates an instance of the HelloWorldExample servlet and names that instance HelloWorld. Because the servlet is located in the examples context, i.e. at <installdir>\apps\servlets\examples, the url-pattern element maps the servlet to /examples/HelloWorldExample/. That is, the container forwards all requests that begin with /examples/HelloWorldExample/ to the HelloWorld instance. This servlet configuration is identical to the configuration for HelloWorldExample in the web.xml file for the examples context.
Chapter 4 explains the context web.xml file and describes how to deploy and configure servlets, filters, and listeners.