title: Generating a Faces Context manually
body: <p>I have two systems I'm trying to integrate. One is built on raw servlets, the new one is build on JSF with IceFaces. I'm trying to facilitate cross-system sign on. The idea is that I have a button in the old system that POSTs the appropriate information to the new site and logs them on. </p>
  
  <p>Well, ideally, I'd like to use just a regular old servlet to facilitate that on the new site. Go to the new site's Servlet, do what it needs to do and the forward onto the dashboard.</p>
  
  <p>Our security is handled via a managed bean. However, by the time you get to the Servlet, there is no faces context. So, how would I create a new faces context?</p>
  
  <p>I have a back up plan in that I can always link to a dummy .iface page which will create the FacesContext for me and then create a backing bean that will do stuff when it gets instanciated and then forward onto the main page. But this feels very much like a hack. </p>
  
  <p>Any help would be appreciated!</p>
  
  <p><strong>EDIT:</strong> I went with the back up way. Basically, I POST to a page like so:</p>
  
  <pre><code>&lt;f:view&gt;
     &lt;ice:outputText value="#{EntryPoint}"/&gt;
  &lt;/f:view
  </code></pre>
  
  <p>The backing bean looking like so...</p>
  
  <pre><code>public EntryPoint() {
        try {
           HttpServletRequest request = (HttpServletRequest) FacesContext.getCurrentInstance().getExternalContext().getRequest();
           HttpServletResponse response = (HttpServletResponse) FacesContext.getCurrentInstance().getExternalContext().getResponse(); 
           String loginID = request.getParameter("loginID");
           //Do some code to load the user/permissions
           response.sendRedirect(
              //The appropriate page
           );
        } catch (IOException ex) {
           logger.error(null, ex);
        } catch (SQLException ex) {
           logger.error(null, ex);
        }
     }
  </code></pre>
  
  <p>This still feels like a hack, but I'm not sure how to get around this. Ideally, I'd POST to a servlet, get the loginID, build the user and put it directly into the managed bean. But, the FacesContext does not exist at that point. </p>
  
  <p>Any other ideas?</p>