title: spring security redirects to last requested page after login session timeout
body: <p>I have implemented spring security for login to my web portal. It works fine except for one issue. I have set session timeout to 5 min. Once timeout happpens and then user click any URL, it gets redirected to logout page.
  But when user re autheticates, user directly lands on the last access page instead of home page which is default target URL.</p>
  
  <p>Spring security file is as below:</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
  &lt;beans:beans xmlns="http://www.springframework.org/schema/security"
      xmlns:beans="http://www.springframework.org/schema/beans"
      xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
      xsi:schemaLocation="http://www.springframework.org/schema/beans  
  
          http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
          http://www.springframework.org/schema/security
          http://www.springframework.org/schema/security/spring-security-3.0.xsd"&gt;
  
      &lt;http auto-config="true"&gt;
          &lt;intercept-url pattern="/index.jsp" access="ROLE_ADMIN,ROLE_USER" /&gt; 
          &lt;intercept-url pattern="/home.html" access="ROLE_ADMIN,ROLE_USER" /&gt;
          &lt;intercept-url pattern="/mdm/accessToken.html" access="ROLE_USER" /&gt;
          &lt;intercept-url pattern="/mdm/enroll.html" access="ROLE_USER" /&gt;
          &lt;intercept-url pattern="/mdm/installApp.html" access="ROLE_USER" /&gt;
          &lt;intercept-url pattern="/mdm/checkStatus.html" access="ROLE_USER" /&gt;
          &lt;intercept-url pattern="/mdm/searchDevice.html" access="ROLE_USER" /&gt;     
          &lt;intercept-url pattern="/admin/*" access="ROLE_ADMIN" /&gt;
          &lt;intercept-url pattern="/account/*" access="ROLE_ADMIN" /&gt;
          &lt;intercept-url pattern="/user/*" access="ROLE_USER" /&gt;      
  
          &lt;form-login login-page="/login.html" default-target-url="/home.html"
                      authentication-failure-url="/loginfailed.html" /&gt;
          &lt;logout logout-url="/logout.html" logout-success-url="/logoutSuccess.html" invalidate-session="true" /&gt;
          &lt;anonymous username="guest" granted-authority="ROLE_GUEST" /&gt;
          &lt;session-management&gt;
              &lt;concurrency-control max-sessions="1"  /&gt;
          &lt;/session-management&gt;
          &lt;session-management invalid-session-url="/logout.html" /&gt;
      &lt;/http&gt;
  
      &lt;authentication-manager&gt;
          &lt;authentication-provider&gt;
              &lt;jdbc-user-service data-source-ref="dataSource"
                  users-by-username-query="select USER as username, password, 'true' as enabled from TBL_USER_MASTER where user=?"
                  authorities-by-username-query="select um.USER as username , rm.ROLE_NAME as authorities from TBL_USER_MASTER um,TBL_ROLE_MASTER rm
              where um.USER=? and um.role_id=rm.role_id" /&gt;
              &lt;password-encoder hash="md5"/&gt;
          &lt;/authentication-provider&gt;
      &lt;/authentication-manager&gt;
  &lt;/beans:beans&gt;  
  </code></pre>