1 Reply Latest reply on Oct 28, 2009 11:54 AM by dpocock.daniel.readytechnology.co.uk

    error-page for 401 not working

    dpocock.daniel.readytechnology.co.uk
      I'm using HTTP basic authentication (not form-based authentication) configured in web.xml.

      When the user fails to authenticate, I want to display a help page, using the <error-page> directive.

      However, I've found that the error page is sent without the 401 status code - so the browser never prompts the user to authenticate in the first place.

      What do I need to put in my Facelets code to tell it to return the page with the 401 code?

      |<error-page>
        <error-code>401</error-code>
        <location>/badPassword.xhtml</location>
      </error-page>

      <security-constraint>
        <web-resource-collection>
          <web-resource-name>secureZone</web-resource-name>
          <url-pattern>/secure-pages/*</url-pattern>
          <http-method>GET</http-method>
          <http-method>POST</http-method>
        </web-resource-collection>
        <auth-constraint>
          <role-name>admin</role-name>
        </auth-constraint>
      </security-constraint>

      <login-config>
        <auth-method>BASIC</auth-method>
        <realm-name>seam-app</realm-name>
      </login-config>
      |