title: Redirecting to Login page if User not Logs in in JSF
body: <p>I am developing a JSF application.
  That is intended for Authourised users only.</p>
  
  <p>So whenever some one trying to access any pages through URL it should redirect to Login .</p>
  
  <p>I am using XHTML as front end. And using JSF framework.</p>
  
  <p>And i am storing Login Bean in Session scope.</p>
  
  <p>And unfortunately I have used Servlets and static pages "response.sendRedirect()".</p>
  
  <p>Thanks in advance.</p>
  
  <p>I think one solution is putting all pages inside WEB-INF but one problem is I am using resonse.sendRedirect() 
  and also I am using Templates with facelets.</p>
  
  <p>Please suggest me. </p>
  
  <hr>
  
  <p>My Login page in folder </p>
  
  <p><code>"/Common/Login.xhtml"
  </code> and some pages in</p>
  
  <pre><code>"/Admin/*.xhtml"
  </code></pre>
  
  <p>and some pages in </p>
  
  <pre><code>`"Employee/*.ahtml"` 
  </code></pre>
  
  <p>how to set Filter for these 2 folders Admin and Employee</p>
  
  <p>I gave like this but request not enering into Filter Servlet</p>
  
  <pre><code>&lt;filter-mapping&gt;    
       &lt;filter-name&gt;LoginFilter&lt;/filter-name&gt;   
        &lt;url-pattern&gt;/faces/Admin/*&lt;/url-pattern&gt;    
       &lt;url-pattern&gt;/faces/Employee/*&lt;/url-pattern&gt;           
  &lt;dispatcher&gt;REQUEST&lt;/dispatcher&gt;
         &lt;dispatcher&gt;FORWARD&lt;/dispatcher&gt;  
     &lt;/filter-mapping&gt;` 
  </code></pre>
  
  <p>if I give like this</p>
  
  <pre><code> &lt;url-pattern&gt;/*&lt;/url-pattern&gt;
  </code></pre>
  
  <p>its going into Infinite loop please give your solution for this prob</p>