title: spring security. forward after login page
body: <p>It is snippet from spring security config:</p>
  
  <pre><code>&lt;form-login login-page="/home.jsp"
                  authentication-failure-url="/loginFailed" default-target-url="/index" /&gt;
                 &lt;logout logout-success-url="/logOut" /&gt;
  </code></pre>
  
  <p>But if I enter successfull I was forward to <code>/logOut</code></p>
  
  <p>if click log out - go to <code>home.jsp</code> .</p>
  
  <p>if failed login - <code>home.jsp</code></p>
  
  <p>What is the strange behaviour?</p>
  
  <p><strong>update</strong></p>
  
  <p>web.xml</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
  &lt;web-app version="2.5" xmlns="http://java.sun.com/xml/ns/javaee"
      xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
      xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"&gt;
  
      &lt;!-- The definition of the Root Spring Container shared by all Servlets 
          and Filters --&gt;
      &lt;context-param&gt;
          &lt;param-name&gt;contextConfigLocation&lt;/param-name&gt;
          &lt;param-value&gt;/WEB-INF/spring/root-context.xml&lt;/param-value&gt;
      &lt;/context-param&gt;
  
      &lt;!-- Creates the Spring Container shared by all Servlets and Filters --&gt;
      &lt;listener&gt;
          &lt;listener-class&gt;org.springframework.web.context.ContextLoaderListener&lt;/listener-class&gt;
      &lt;/listener&gt;
  
      &lt;!-- Processes application requests --&gt;
      &lt;servlet&gt;
          &lt;servlet-name&gt;appServlet&lt;/servlet-name&gt;
          &lt;servlet-class&gt;org.springframework.web.servlet.DispatcherServlet&lt;/servlet-class&gt;
          &lt;init-param&gt;
              &lt;param-name&gt;contextConfigLocation&lt;/param-name&gt;
              &lt;param-value&gt;/WEB-INF/spring/appServlet/servlet-context.xml&lt;/param-value&gt;
          &lt;/init-param&gt;
          &lt;load-on-startup&gt;1&lt;/load-on-startup&gt;
      &lt;/servlet&gt;
  
      &lt;servlet-mapping&gt;
          &lt;servlet-name&gt;appServlet&lt;/servlet-name&gt;
          &lt;url-pattern&gt;/&lt;/url-pattern&gt;
      &lt;/servlet-mapping&gt;
  
      &lt;filter&gt;
          &lt;filter-name&gt;springSecurityFilterChain&lt;/filter-name&gt;
          &lt;filter-class&gt;org.springframework.web.filter.DelegatingFilterProxy&lt;/filter-class&gt;
      &lt;/filter&gt;
      &lt;filter-mapping&gt;
          &lt;filter-name&gt;springSecurityFilterChain&lt;/filter-name&gt;
          &lt;url-pattern&gt;/*&lt;/url-pattern&gt;
      &lt;/filter-mapping&gt;
  
      &lt;welcome-file-list&gt;
          &lt;welcome-file&gt;home.jsp&lt;/welcome-file&gt;
      &lt;/welcome-file-list&gt;
  &lt;/web-app&gt;
  </code></pre>
  
  <p>root-context.xml</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
  &lt;beans xmlns="http://www.springframework.org/schema/beans"
      xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:aop="http://www.springframework.org/schema/aop"
      xmlns:context="http://www.springframework.org/schema/context"
      xmlns:jee="http://www.springframework.org/schema/jee" xmlns:lang="http://www.springframework.org/schema/lang"
      xmlns:p="http://www.springframework.org/schema/p" xmlns:tx="http://www.springframework.org/schema/tx"
      xmlns:util="http://www.springframework.org/schema/util"
      xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
          http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop.xsd
          http://www.springframework.org/schema/jee http://www.springframework.org/schema/jee/spring-jee.xsd
          http://www.springframework.org/schema/lang http://www.springframework.org/schema/lang/spring-lang.xsd
          http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx.xsd
          http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util.xsd"&gt;
      &lt;!-- Root Context: defines shared resources visible to all other web components --&gt;
      &lt;!-- Настраивает управление транзакциями с помощью аннотации @Transactional --&gt;
     &lt;!--  --&gt;
  
  
      &lt;import resource="classpath:spring/BeanConfig.xml" /&gt;
      &lt;!-- Файл с настройками Security --&gt;
      &lt;import resource="security_config.xml" /&gt;
  &lt;!--    &lt;bean id="messageSource"        class="org.springframework.context.support.ReloadableResourceBundleMessageSource‌​"&gt; --&gt;
  &lt;!--        &lt;property name="basename" value="/WEB-INF/messages/messages" /&gt; --&gt;
  &lt;!--    &lt;/bean&gt; --&gt;
  
  &lt;/beans&gt;
  </code></pre>
  
  <p>securuty_config.xml</p>
  
  <pre><code>&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.1.xsd
      http://www.springframework.org/schema/security
      http://www.springframework.org/schema/security/spring-security-3.1.xsd"&gt;
     &lt;http use-expressions="true" &gt;   
  
          &lt;intercept-url pattern="/home.jsp" access="permitAll" /&gt; 
  
          &lt;intercept-url pattern="/*" access="isAuthenticated()"/&gt; 
  
  
          &lt;form-login login-page="/home.jsp"
              authentication-failure-url="/loginFailed" default-target-url="/index" /&gt;
          &lt;logout logout-success-url="/logOut" /&gt;
      &lt;/http&gt;
      &lt;authentication-manager&gt;
          &lt;authentication-provider ref="provider" /&gt; 
  &lt;!-- &lt;authentication-provider&gt; --&gt;
  &lt;!--    &lt;user-service&gt; --&gt;
  &lt;!--    &lt;user name="name" authorities="ROLE_USER"/&gt; --&gt;
  &lt;!--    &lt;/user-service&gt; --&gt;
  &lt;!-- &lt;/authentication-provider&gt; --&gt;
      &lt;/authentication-manager&gt;
  
  &lt;/beans:beans&gt;
  </code></pre>
  
  <p>form authenthification fragment:</p>
  
  <pre><code>&lt;form method="POST" action="&lt;c:url value="/j_spring_security_check" /&gt;"
  </code></pre>