title: Redirecting to login page after Session Expired in Spring
body: <p>1 I am facing a problem. I have 3 role in my project user,admin,expert.
  2 3 different login page for different user.
  3 What I have want is when ever the session is expired,and after that if User did any event the page should direct to according to there role.
  e.g User should get redirect to User login and Admin to admin a login.</p>
  
  <p>I have read many document about it.Some has give idea of adding filter and check the session in filter.
  But the issue with that is I did not get the role in filter.'
  So Do SpringSecurityHolder will work inside Filter.</p>
  
  <p>I have also read about the ApplicationListerner which take Event.
  I have return the code but I dont know how to direct from inside the listerner class</p>
  
  <pre><code>import java.util.List;
  
  import org.springframework.context.ApplicationListener;
  import org.springframework.security.core.Authentication;
  import org.springframework.security.core.GrantedAuthority;
  import org.springframework.security.core.context.SecurityContext;
  import org.springframework.security.core.context.SecurityContextHolder;
  import org.springframework.security.web.session.HttpSessionDestroyedEvent;
  
  public class SessionTimeoutHandler  implements ApplicationListener&lt;HttpSessionDestroyedEvent&gt;{
  
      @Override
      public void onApplicationEvent(HttpSessionDestroyedEvent event) {
  
          List&lt;SecurityContext&gt; lstSecurityContext = event
                  .getSecurityContexts();
  
          for (SecurityContext securityContext : lstSecurityContext)
          {
              Authentication authentication = SecurityContextHolder.getContext().getAuthentication();
  
              List&lt;GrantedAuthority&gt; authList = (List&lt;GrantedAuthority&gt;) authentication
                      .getAuthorities();
              String userRole = authList.get(0).getAuthority();
  
              if(userRole.equals("ROLE_ADMIN")){
  
  
              }else if(userRole.equals("ROLE_EXPERT")){
  
              }else{
  
              }
  
          }
  
      }
  
  }
  </code></pre>
  
  <p>Please help me out How will I will be able to redirect the page.</p>
  
  <p>Thanks for the help</p>