title: Container managed login page does not render JSF components
body: <p>I searched for a solution but could not find an answer for my specific issue. I have a login.xhtml page but the JSF tags are not rendered. When I successfully log in, the tags are renderen correctly. so somehow the login.xhtml does not pass through the faces servlet. This seems strange because all is configured correctly. How can I force the login.xhtml to be rendered correctly?</p>
  
  <p>Here is my web.xml portion</p>
  
  <pre><code>&lt;login-config&gt;
      &lt;auth-method&gt;FORM&lt;/auth-method&gt;
      &lt;realm-name&gt;file&lt;/realm-name&gt;
      &lt;form-login-config&gt;
          &lt;form-login-page&gt;/login.xhtml&lt;/form-login-page&gt;
          &lt;form-error-page&gt;/error.xhtml&lt;/form-error-page&gt;
      &lt;/form-login-config&gt;
  &lt;/login-config&gt;
  
  &lt;servlet-mapping&gt;
      &lt;servlet-name&gt;Faces Servlet&lt;/servlet-name&gt;
      &lt;url-pattern&gt;*.jsf&lt;/url-pattern&gt;
  &lt;/servlet-mapping&gt;
  </code></pre>
  
  <p>Login.xhtml</p>
  
  <pre><code>&lt;ui:composition xmlns="http://www.w3.org/1999/xhtml"
  xmlns:ui="http://java.sun.com/jsf/facelets"
  xmlns:f="http://java.sun.com/jsf/core"
  xmlns:h="http://java.sun.com/jsf/html"
  xmlns:p="http://primefaces.org/ui"
  template="/WEB-INF/templates/eps_template.xhtml"&gt;
  &lt;ui:define name="body"&gt;
  
      &lt;h2&gt;Hello, please log in:&lt;/h2&gt;
      &lt;form name="loginForm" method="post" action="j_security_check"&gt;
          &lt;p&gt;
              &lt;strong&gt;&lt;label for="username"&gt;Please type your user
                      name: &lt;/label&gt; &lt;/strong&gt; &lt;input id="username" type="text" name="j_username"
                  size="25" /&gt;
          &lt;/p&gt;
          &lt;p&gt;
              &lt;strong&gt;&lt;label for="password"&gt;Please type your
                      password: &lt;/label&gt; &lt;/strong&gt; &lt;input id="password" type="password" size="15"
                  name="j_password" /&gt;
          &lt;/p&gt;
          &lt;p&gt;
              &lt;input type="submit" value="Submit" /&gt; &lt;input type="reset"
                  value="Reset" /&gt;
          &lt;/p&gt;
      &lt;/form&gt;
  
  &lt;/ui:define&gt;
  &lt;/ui:composition&gt;
  </code></pre>
  
  <p>So the html form is shown correctly, but the template components are not. The output is:</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
  &lt;ui:composition xmlns="http://www.w3.org/1999/xhtml"
  xmlns:ui="http://java.sun.com/jsf/facelets"
  xmlns:f="http://java.sun.com/jsf/core"
  xmlns:h="http://java.sun.com/jsf/html"
  xmlns:p="http://primefaces.org/ui"
  template="/WEB-INF/templates/eps_template.xhtml"&gt;
  &lt;ui:define name="body"&gt;
  
      &lt;h2&gt;Hello, please log in:&lt;/h2&gt;
      &lt;form name="loginForm" method="post" action="j_security_check"&gt;
          &lt;p&gt;
              &lt;strong&gt;&lt;label for="username"&gt;Please type your user
                      name: &lt;/label&gt; &lt;/strong&gt; &lt;input id="username" type="text" name="j_username"
                  size="25" /&gt;
  
          &lt;/p&gt;
          &lt;p&gt;
              &lt;strong&gt;&lt;label for="password"&gt;Please type your
                      password: &lt;/label&gt; &lt;/strong&gt; &lt;input id="password" type="password" size="15"
                  name="j_password" /&gt;
          &lt;/p&gt;
          &lt;p&gt;
              &lt;input type="submit" value="Submit" /&gt; &lt;input type="reset"
                  value="Reset" /&gt;
          &lt;/p&gt;
  
      &lt;/form&gt;
  
  &lt;/ui:define&gt;
  &lt;/ui:composition&gt;
  </code></pre>
  
  <p>Update 31 January 2012</p>
  
  <p>Configuration:
  Glassfish 3.1
  Primefaces 3.1
  JSF 2.1</p>
  
  <p>I have a index.html page which forwards to home.jsf. But the container notices the user is not logged in so it redirects to login.xhtml.</p>
  
  <p>If I add only the *.jsf to the web.xml, all is working fine but the login.jsf does not render JSF tags.</p>
  
  <pre><code>&lt;url-pattern&gt;*.jsf&lt;/url-pattern&gt;
  &lt;url-pattern&gt;*.xhtml&lt;/url-pattern&gt;
  </code></pre>
  
  <p>If I also add *.xhtml the login.jsf page does render tags but not properly according to the Primefaces skin. When I click submit the jquery.js is printed to the screen.</p>
  
  <p>Here is the complete web.xml</p>
  
  <pre><code>&lt;servlet&gt;
      &lt;servlet-name&gt;Faces Servlet&lt;/servlet-name&gt;
      &lt;servlet-class&gt;javax.faces.webapp.FacesServlet&lt;/servlet-class&gt;
      &lt;load-on-startup&gt;1&lt;/load-on-startup&gt;
  &lt;/servlet&gt;
  &lt;servlet-mapping&gt;
      &lt;servlet-name&gt;Faces Servlet&lt;/servlet-name&gt;
      &lt;url-pattern&gt;*.jsf&lt;/url-pattern&gt;
      &lt;url-pattern&gt;*.xhtml&lt;/url-pattern&gt;
      &lt;url-pattern&gt;*.html&lt;/url-pattern&gt;
  &lt;/servlet-mapping&gt;
  &lt;context-param&gt;
      &lt;param-name&gt;facelets.DEVELOPMENT&lt;/param-name&gt;
      &lt;param-value&gt;true&lt;/param-value&gt;
  &lt;/context-param&gt;
  
  &lt;!-- Primefaces --&gt;
  &lt;servlet&gt;
      &lt;servlet-name&gt;Resource Servlet&lt;/servlet-name&gt;
      &lt;servlet-class&gt;org.primefaces.resource.ResourceServlet&lt;/servlet-class&gt;
  &lt;/servlet&gt;
  &lt;servlet-mapping&gt;
      &lt;servlet-name&gt;Resource Servlet&lt;/servlet-name&gt;
      &lt;url-pattern&gt;/primefaces_resource/*&lt;/url-pattern&gt;
  &lt;/servlet-mapping&gt;
  
  &lt;context-param&gt;
      &lt;param-name&gt;javax.faces.PROJECT_STAGE&lt;/param-name&gt;
      &lt;param-value&gt;Production&lt;/param-value&gt;
  &lt;/context-param&gt;
  &lt;context-param&gt;
      &lt;param-name&gt;javax.faces.STATE_SAVING_METHOD&lt;/param-name&gt;
      &lt;param-value&gt;server&lt;/param-value&gt;
  &lt;/context-param&gt;
  &lt;context-param&gt;
      &lt;param-name&gt;primefaces.THEME&lt;/param-name&gt;
      &lt;param-value&gt;bluesky&lt;/param-value&gt;
  &lt;/context-param&gt;
  &lt;filter&gt;
      &lt;filter-name&gt;PrimeFaces FileUpload Filter&lt;/filter-name&gt;
      &lt;filter-class&gt;org.primefaces.webapp.filter.FileUploadFilter&lt;/filter-class&gt;
      &lt;init-param&gt;
          &lt;param-name&gt;thresholdSize&lt;/param-name&gt;
          &lt;param-value&gt;5120&lt;/param-value&gt;
      &lt;/init-param&gt;
      &lt;init-param&gt;
          &lt;param-name&gt;uploadDirectory&lt;/param-name&gt;
          &lt;param-value&gt;/****&lt;/param-value&gt;
      &lt;/init-param&gt;
  &lt;/filter&gt;
  &lt;filter-mapping&gt;
      &lt;filter-name&gt;PrimeFaces FileUpload Filter&lt;/filter-name&gt;
      &lt;servlet-name&gt;Faces Servlet&lt;/servlet-name&gt;
  &lt;/filter-mapping&gt;
  
  
  &lt;!-- security --&gt;
  
  &lt;login-config&gt;
      &lt;auth-method&gt;FORM&lt;/auth-method&gt;
      &lt;realm-name&gt;file&lt;/realm-name&gt;
      &lt;form-login-config&gt;
          &lt;form-login-page&gt;/login.xhtml&lt;/form-login-page&gt;
          &lt;form-error-page&gt;/error.xhtml&lt;/form-error-page&gt;
      &lt;/form-login-config&gt;
  &lt;/login-config&gt;
  
  &lt;security-role&gt;
      &lt;role-name&gt;epsadmin&lt;/role-name&gt;
  &lt;/security-role&gt;
  &lt;security-constraint&gt;
      &lt;web-resource-collection&gt;
          &lt;web-resource-name&gt;Admin&lt;/web-resource-name&gt;
          &lt;url-pattern&gt;/*&lt;/url-pattern&gt;
      &lt;/web-resource-collection&gt;
      &lt;auth-constraint&gt;
          &lt;role-name&gt;admin&lt;/role-name&gt;
      &lt;/auth-constraint&gt;
  &lt;/security-constraint&gt;
  
  &lt;security-constraint&gt;
      &lt;display-name&gt;Restrict raw XHTML documents&lt;/display-name&gt;
      &lt;web-resource-collection&gt;
          &lt;web-resource-name&gt;XHTML&lt;/web-resource-name&gt;
          &lt;url-pattern&gt;*.xhtml&lt;/url-pattern&gt;
      &lt;/web-resource-collection&gt;
      &lt;auth-constraint /&gt;
  &lt;/security-constraint&gt;
  </code></pre>
  
  <p>Update after answer 2 by BalusC. This is now the complete web.xml</p>
  
  <pre><code>&lt;servlet&gt;
      &lt;servlet-name&gt;Faces Servlet&lt;/servlet-name&gt;
      &lt;servlet-class&gt;javax.faces.webapp.FacesServlet&lt;/servlet-class&gt;
      &lt;load-on-startup&gt;1&lt;/load-on-startup&gt;
  &lt;/servlet&gt;
  &lt;servlet-mapping&gt;
      &lt;servlet-name&gt;Faces Servlet&lt;/servlet-name&gt;
      &lt;url-pattern&gt;*.jsf&lt;/url-pattern&gt;
  &lt;/servlet-mapping&gt;
  
  &lt;context-param&gt;
      &lt;param-name&gt;facelets.DEVELOPMENT&lt;/param-name&gt;
      &lt;param-value&gt;true&lt;/param-value&gt;
  &lt;/context-param&gt;
  
  &lt;context-param&gt;
      &lt;param-name&gt;javax.faces.PROJECT_STAGE&lt;/param-name&gt;
      &lt;param-value&gt;Production&lt;/param-value&gt;
  &lt;/context-param&gt;
  &lt;context-param&gt;
      &lt;param-name&gt;javax.faces.STATE_SAVING_METHOD&lt;/param-name&gt;
      &lt;param-value&gt;server&lt;/param-value&gt;
  &lt;/context-param&gt;
  &lt;context-param&gt;
      &lt;param-name&gt;primefaces.THEME&lt;/param-name&gt;
      &lt;param-value&gt;bluesky&lt;/param-value&gt;
  &lt;/context-param&gt;
  &lt;filter&gt;
      &lt;filter-name&gt;PrimeFaces FileUpload Filter&lt;/filter-name&gt;
      &lt;filter-class&gt;org.primefaces.webapp.filter.FileUploadFilter&lt;/filter-class&gt;
      &lt;init-param&gt;
          &lt;param-name&gt;thresholdSize&lt;/param-name&gt;
          &lt;param-value&gt;5120&lt;/param-value&gt;
      &lt;/init-param&gt;
      &lt;init-param&gt;
          &lt;param-name&gt;uploadDirectory&lt;/param-name&gt;
          &lt;param-value&gt;/tempupload&lt;/param-value&gt;
      &lt;/init-param&gt;
  &lt;/filter&gt;
  &lt;filter-mapping&gt;
      &lt;filter-name&gt;PrimeFaces FileUpload Filter&lt;/filter-name&gt;
      &lt;servlet-name&gt;Faces Servlet&lt;/servlet-name&gt;
  &lt;/filter-mapping&gt;
  
  
  &lt;welcome-file-list&gt;
      &lt;welcome-file&gt;home.jsf&lt;/welcome-file&gt;
  &lt;/welcome-file-list&gt;
  
  
  &lt;login-config&gt;
      &lt;auth-method&gt;FORM&lt;/auth-method&gt;
      &lt;realm-name&gt;file&lt;/realm-name&gt;
      &lt;form-login-config&gt;
          &lt;form-login-page&gt;/login.jsf&lt;/form-login-page&gt;
          &lt;form-error-page&gt;/error.jsf&lt;/form-error-page&gt;
      &lt;/form-login-config&gt;
  &lt;/login-config&gt;
  
  &lt;security-role&gt;
      &lt;role-name&gt;admin&lt;/role-name&gt;
  &lt;/security-role&gt;
  &lt;security-constraint&gt;
      &lt;web-resource-collection&gt;
          &lt;web-resource-name&gt;Admin&lt;/web-resource-name&gt;
          &lt;url-pattern&gt;*.jsf&lt;/url-pattern&gt;
      &lt;/web-resource-collection&gt;
      &lt;auth-constraint&gt;
          &lt;role-name&gt;admin&lt;/role-name&gt;
      &lt;/auth-constraint&gt;
  &lt;/security-constraint&gt;
  
  &lt;error-page&gt;
      &lt;error-code&gt;403&lt;/error-code&gt;
      &lt;location&gt;/errorpages/error403.jsf&lt;/location&gt;
  &lt;/error-page&gt;
  &lt;error-page&gt;
      &lt;error-code&gt;404&lt;/error-code&gt;
      &lt;location&gt;/errorpages/error404.jsf&lt;/location&gt;
  &lt;/error-page&gt;
  &lt;error-page&gt;
      &lt;error-code&gt;500&lt;/error-code&gt;
      &lt;location&gt;/errorpages/error500.jsf&lt;/location&gt;
  &lt;/error-page&gt;
  &lt;error-page&gt;
      &lt;exception-type&gt;com.*******.ApplicationException&lt;/exception-type&gt;
      &lt;location&gt;/errorpages/error500.jsf&lt;/location&gt;
  &lt;/error-page&gt;
  </code></pre>
  
  <p>This is the url I get when pressing the submit button</p>
  
  <pre><code>csman/javax.faces.resource/primefaces.js.jsf?ln=primefaces&amp;v=3.1-SNAPSHOT
  </code></pre>
  
  <p>This is the output.</p>
  
  <pre><code>PrimeFaces={escapeClientId:function(a){return"#"+a ..........etc
  </code></pre>
  
  <p>However, when I press connect to the start URL again, I am successfully directed to the home.jsf page. So the login procedure went OK.</p>
  
  <p>Not that the login.jsf page displays JSF tags but they are not skinned.</p>
  
  <p>Weird?!</p>