Imagine you have an HTTP request for "/MyServlet". The web container will create a processing chain like this request->MyFilter->MyServlet.
Now imagine a different HTTP request for "/index.jsp". In this case, the MyServlet servlet is not applicable to the request and therefore the MyFilter filter is also not applicable.
Given these servlet and filter mappings, "/MyServlet" is the only HTTP request URL that will be handled by the filter and this is because "/MyServlet" is the only URL pattern that matches the MyServlet servlet.
Joined: Feb 17, 2008
Thanks Bryan. So basically the container once receives the request for /MyServlet it goes and checks in the <servlet-mapping> that has the matching URL, then finds the servlet name and goes to the <filter-mapping> where it finds the matching <filter-name> and calls that particular filter. Once filter finishes, the container calls the correspoding servlet with the name given in <servlet-name>. Correct me If I am wrong.