title: Spring session management in mvc, Spring security session vs http session
body: <p>After successful login i want to proceed with further request processing with new url. But the  url is invoking exposed service in spring mvc where security configuration doesn't check the session authentication for coming url.Please take a look below code.</p>
  
  <pre><code>&lt;http auto-config="true" use-expressions="true"&gt;
      &lt;!-- &lt;intercept-url pattern="/**" access="isAuthenticated()" /&gt; --&gt;
      &lt;intercept-url pattern="/home*" access="isAuthenticated()" /&gt;
      &lt;intercept-url pattern="/admin*" access="isAuthenticated()" /&gt;
      &lt;form-login login-page="/" default-target-url="/home"
          authentication-failure-url="/accessdenied" always-use-default-target="false"/&gt;
      &lt;logout logout-success-url="/" /&gt;
      &lt;anonymous username="guest" granted-authority="ROLE_GUEST" /&gt;
      &lt;session-management invalid-session-url="/" session-authentication-error-url="/login.jsp?error=alreadyLogin"&gt;
         &lt;concurrency-control max-sessions="1"  expired-url="/login.jsp?error=sessionExpiredDuplicateLogin" error-if-maximum-exceeded="false"/&gt;
      &lt;/session-management&gt;
      &lt;remember-me /&gt;
  &lt;/http&gt;
  </code></pre>
  
  <p>When jsp page submits login authentication J_security_check the target url invoked which subsequently calls interceptor pattern /home* and authenticates the login credentials.</p>
  
  <p>if i'm calling the exposed service before login    <strong>"/address/userid/"</strong>   it directly invokes the service method how to make it session bound, if session exist get the data otherwise not.</p>
  
  <p>how different spring security session from http session,how to maintain spring security session like http session in spring mvc.</p>
  
  <p>if i'm adding <code>&lt;intercept-url pattern="/**" access="isAuthenticated()" /&gt;</code> it doesn't work, it doesn't show login jsp as well.Where i am doing wrong please clarify.</p>
  
  <p>How to distinguish userid/pwd in authentication manager as per given below, as single ? takes first parameter.</p>
  
  <pre><code>&lt;authentication-manager&gt;
      &lt;authentication-provider&gt;
          &lt;!-- &lt;user-service&gt; &lt;user name="admin" password="secret" authorities="ROLE_ADMIN,ROLE_USER"/&gt; 
              &lt;/user-service&gt; --&gt;
          &lt;jdbc-user-service data-source-ref="dataSource" 
              users-by-username-query="SELECT USER_NAME,USER_PWD, 'true' as enabled from LOGIN_USER where USER_NAME=?"
              authorities-by-username-query="select LOGIN_USER.USER_NAME , LOGIN_USER.ROLE_ID as authorities from LOGIN_USER
              where LOGIN_USER.USER_NAME =?" /&gt;
      &lt;/authentication-provider&gt;
  &lt;/authentication-manager&gt;
  </code></pre>
  
  <p>I have come across few sites it describes only login spring security session management.i couldn't get clarity.Thanks in advance.</p>