Search code examples
javajspjakarta-eeservletsservlet-listeners

Form Authentication - Listener


I use FORM-based authentication method in Java JSP/Servlet app. I want to "do something" after a successful login. Is there any listener which help me to do it? I don't want to put any code at the beginning of each page.


Solution

  • Generally, authentication being a cross-cutting concern, you would have extracted it to an authentication ServletFilter that is applied to all the servlets that need the user to be authenticated. If you have such a filter, this logic would go into that filter after successful authentication.