title: How to use j_security_check jsf
body: <p>I want to use j_security_check authentication in order to validate the user credentials.</p>
  
  <p>Basically what I am trying to achieve is when the user press submit then in case he is using wrong credentials then a message (p:growl) will show and if it’s successful then the dialog will closed.</p>
  
  <p>There are many examples in the web but unfortunately I still can’t understand how to complete this puzzle :(</p>
  
  <p>In my project I am using primefaces 4.0 &amp; weblogic  10.3.2.0 (JAVA EE 5).</p>
  
  <p>some code example:
  </p>
  
  <pre><code>&lt;p:dialog id="dialog" widgetVar="dlg" resizable="false"&gt; 
      &lt;h:form id="fLogin" prependId="false"
              onsubmit="document.getElementById('fLogin').action = 'j_security_check';"&gt;        
          &lt;h:panelGrid columns="2" cellpadding="5"&gt;  
              &lt;h:outputLabel for="j_username" value="Username:" /&gt;  
              &lt;p:inputText value="#{expBean.username}"   
                           id="j_username" label="username"/&gt;  
              &lt;h:outputLabel for="j_password" value="Password:" /&gt;  
              &lt;h:inputSecret value="#{expBean.password}"   
                             id="j_password" label="password"/&gt;  
              &lt;p:commandButton id="submitButton" 
                               value="Submit"
                               actionListener="#{expBean.run}" /&gt; 
          &lt;/h:panelGrid&gt; 
      &lt;/h:form&gt;
  &lt;/p:dialog&gt;
  </code></pre>
  
  <p>web.xml</p>
  
  <pre><code>&lt;servlet-mapping&gt;
      &lt;servlet-name&gt;Faces Servlet&lt;/servlet-name&gt;
      &lt;url-pattern&gt;/faces/*&lt;/url-pattern&gt;
      &lt;url-pattern&gt;*.jsf&lt;/url-pattern&gt;
  &lt;/servlet-mapping&gt;
  &lt;security-constraint&gt;
      &lt;web-resource-collection&gt;
          &lt;web-resource-name&gt;main&lt;/web-resource-name&gt;
          &lt;description/&gt;
          &lt;url-pattern&gt;main.jsf&lt;/url-pattern&gt;
          &lt;http-method&gt;POST&lt;/http-method&gt;
      &lt;/web-resource-collection&gt;
  &lt;/security-constraint&gt;
  &lt;login-config&gt;
      &lt;auth-method&gt;BASIC&lt;/auth-method&gt;
      &lt;realm-name&gt;my-realm&lt;/realm-name&gt;
  &lt;/login-config&gt;
  &lt;security-role&gt;
      &lt;description/&gt;
      &lt;role-name&gt;MyRole&lt;/role-name&gt;
  &lt;/security-role&gt;
  </code></pre>
  
  <p>exeBean:</p>
  
  <pre><code>   public void run() {
  
  
        FacesContext facesContext = FacesContext.getCurrentInstance();
  
     }
  </code></pre>
  
  <p>Any guidelines and useful example will be much appreciated </p>
  
  <p>Thanks</p>