Assume this in web.xml
<
servlet>
<servlet-name> Login </servlet-name>
<servlet-class> LoginServlet </servlet-class>
</servlet>
<servlet-mapping>
<servlet-name> Login </servlet-name>
<url-pattern> /login </url-pattern>
</servlet-mapping>
servlet-mapping : You have a servlet-mapping corresponding to every URL
pattern that you want your web application to support. The value of the url-pattern tag is the form action. For instance, if your application context is, say, 'shopping', then the form action will be "/shopping/login"
servlet : You have a servlet tag for every servlet of your application.
The container looks for the request URI. In this case, it is "/login" after the context has been stripped out. It takes the servlet name for this URI as "Login" (from <servlet-name> in <servlet-mapping>
, goes to all <servlet> tags and looks out for one with this name. It takes the class "LoginServlet" from the <servlet-class> tag of the matching <servlet> tag and executes the request method in it (doGet, doPost ...)