Search code examples
springspring-mvcauthenticationfront-controller

Where should I put the login logic? DispatcherServlet or a Filter?


The following 2 things both implement the front controller pattern:

  1. DispatcherServlet defined by Spring
  2. Filter defined by servlet spec

I think login logic should be placed in the front controller. But which one should I use in a Spring MVC web application?


Solution

  • Instead of implementing that by your own, I strongly recommend to use Spring-Security.

    BTW: The way Spring-Security hooks into the HTTP-Request handling process (the "entry"-point), is based on a Servlet filter (org.springframework.web.filter.DelegatingFilterProxy).