- Whenever client makes a request to a servlet that request is received by server and server goes to a predefined file called web.xml for the details about a servlet.
- web.xml file always gives the details of the servlets which are available in the server.
- If the server is not able to find the requested servlet by the client then server generates an error (resource not found) [A resource is a program which resides in server].
- If the requested servlet is available in web.xml then server will go to the servlet, executes the servlet and gives response back to client.
Every web.xml will contain the following entries:
- While server is executing web.xml control goes to <url-pattern> of <servlet-mapping> tag. If the requested url and <url-name> web.xml is same then control goes to <servlet- class> tag of <servlet> and takes the <servlet-name> and executes.
- If the <url-pattern> is not matching, server generates an error.