JSF error - Why your JSF error message might not be displayed

Using JavaServer Faces (JSF), if you can't see the error message (FacesError) you're creating in your controller/handler when you forward to a new JSP (JavaServer Page), the problem may be that you have a "redirect" tag in your faces-config.xml file.

For example, the following JSF faces-config.xml example shows the problem, where I do have a redirect tag when I bounce control back to the login.jsp page:

<><navigation-rule>
 <from-view-id>/login.jsp</from-view-id>
    <navigation-case>
      <from-outcome>login-success</from-outcome>
      <to-view-id>/main.jsp</to-view-id>
      <redirect/>
    </navigation-case>

    <!-- the "redirect" tag below is bad; your error message (FacesError) will never be seen -->
    <navigation-case>
      <from-outcome>login-failure</from-outcome>
      <to-view-id>/login.jsp</to-view-id>
      <redirect/>
    </navigation-case>
</navigation-rule>

Fortunately this is a simple fix. To make sure users do see your JSF error message (FacesError), just take the redirect tag out of your JSF navigation rule, as shown here:

<><navigation-rule>
  <from-view-id>/login.jsp</from-view-id>
  <navigation-case>
    <from-outcome>login-success</from-outcome>
    <to-view-id>/main.jsp</to-view-id>
    <redirect/>
  </navigation-case>

  <!-- taking the redirect tag out of here let's the user see your error message -->
  <navigation-case>
    <from-outcome>login-failure</from-outcome>
    <to-view-id>/login.jsp</to-view-id>
  </navigation-case>
</navigation-rule>