title: Spring Security
body: <p>i am having problems with spring security and displaying error messages </p>
  
  <p>here is what i have in my root-context.xml</p>
  
  <pre><code>   `&lt;context:property-placeholder location="classpath:config.properties" /&gt; 
      &lt;!-- Register the Customer.properties --&gt;
      &lt;bean id="messageSource"
          class="org.springframework.context.support.ResourceBundleMessageSource"&gt;
         &lt;property name="basename" value="mymessages" /&gt;
      &lt;/bean&gt;
  
  &lt;security:http auto-config='true'&gt;
  &lt;security:intercept-URL pattern="/login" access="IS_AUTHENTICATED_ANONYMOUSLY" /&gt;
  &lt;security:intercept-URL pattern="/**" access="ROLE_USER" /&gt;
  &lt;security:form-login login-page='/login' default-target-url="/" 
      authentication-failure-URL="/loginfailed"/&gt;
  &lt;security:logout logout-success-url="/" logout-URL="/j_spring_security_logout" /&gt;   
  
  &lt;/security:http&gt;
  &lt;security:authentication-manager&gt; 
  &lt;security:authentication-provider&gt;
  &lt;security:user-service&gt;
  &lt;security:user name="billy" password="123456" authorities="ROLE_USER" /&gt;     
  &lt;/security:user-service&gt;
  &lt;/security:authentication-provider&gt;
  &lt;/security:authentication-manager&gt;`
  </code></pre>
  
  <p>and in my web.xml is</p>
  
  <pre><code>&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;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;
  </code></pre>
  
  <p>and my .jsp is</p>
  
  <pre><code>&lt;body&gt;
      &lt;%@ include file="include/login1.jsp"%&gt;
  
      &lt;c:if test="${not empty error}"&gt;
      &lt;div class="errorblock"&gt;Your login attempt was not successful, try again.&lt;br/&gt; Caused :
      &lt;/div&gt;
      &lt;/c:if&gt;
  
  &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p>when i login with wrong user credentials the first time it just reloads the login page. then if i login with the correct login credentials it will the load login with the text  "Your login attempt was not successful, try again. Caused :" but no spring message saying bad credentials after cause : 
  any help on this matter is much appreciated </p>