Hi, i have an application which is developed on MVC architecture using servletsJSP and java (Hibernate). I want to check weather the user is logged in on not for viewing particular pages so i want to implement a filter for that one. My doubt is how to map only "servlets"(nearly 50- 60) to that filter in web.xml file.
Thanks in advance
Filters are applied to URL patterns, in a similar way that servlets are. If you need to apply the filter to all servlets but nothing else but servlets you must make sure the servlet URL patterns match the filter URL patterns one on one. This means that you can't have a filter URL pattern where there is no matching servlet URL pattern (because you will then filter too much), but you also can't have a servlet URL pattern where there is no matching filter URL pattern (because you will then not filter enough).
If you have to apply the filter to some specific servlet then you will have to mapped filter for those servelets.
If you want to run on only with servlet then use .java pattern instead of * in filter url mapping.