title: Facelets error page as the response has already been committed. jsf
body: <p>I perform this redirect :-</p>
  
  <pre><code>   objExternalContext.redirect("http://blogger.blogdns.com:8080/Blogger/Common/LoginRequestProcessor.jsp;jsessionid=" + objHttpSession.getId() + "?j_username="+ userName + "&amp;j_password=" + password + "&amp;rememberMe=" + rememberMe);
  </code></pre>
  
  <p>to page LoginRequestProcessor.jsp :-</p>
  
  <pre><code>&lt;%@page contentType="text/html" pageEncoding="UTF-8"%&gt;
  &lt;%@taglib uri="http://java.sun.com/jstl/core_rt" prefix="c" %&gt;
  &lt;!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
      "http://www.w3.org/TR/html4/loose.dtd"&gt;
  
  &lt;html&gt;
      &lt;head&gt;
  
          &lt;title&gt;JSP Page&lt;/title&gt;
          &lt;script type="text/javascript"&gt;
              window.onload = function(){
                  document.forms[0].submit();
              }
          &lt;/script&gt;
  
      &lt;/head&gt;
      &lt;body style="background: black;"&gt;
          &lt;div style="color: white;"&gt;
  
  
              &lt;center&gt;&lt;h1&gt;Please wait login is being processed.&lt;/h1&gt;&lt;/center&gt;
          &lt;/div&gt;
  
  
          &lt;%
              //change session id because it gets lost while switching from https to http
  
              System.out.println("Cookie in jsp " + request.getSession(true).getId());
          %&gt;
  
          &lt;form method="POST" action="j_security_check;jsessionid=&lt;%= request.getSession(true).getId()%&gt;" id ="frm"&gt;
  
              &lt;input type="hidden" name= "j_username" value="${param.j_username}"/&gt;
  
              &lt;input type="hidden" name = "j_password" value="${param.j_password}"/&gt;
              &lt;input style="display: none;" type="submit" value="Submit"/&gt;
          &lt;/form&gt;
      &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p>And i get this error :-</p>
  
  <pre><code>WARNING: JSF1087: Unable to generate Facelets error page as the response has already been committed.
  SEVERE: javax.faces.FacesException
  javax.faces.FacesException
          at com.sun.faces.context.ExceptionHandlerImpl.handle(ExceptionHandlerImpl.java:136)
          at com.sun.faces.lifecycle.Phase.doPhase(Phase.java:119)
          at com.sun.faces.lifecycle.RestoreViewPhase.doPhase(RestoreViewPhase.java:110)
          at com.sun.faces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:118)
          at javax.faces.webapp.FacesServlet.service(FacesServlet.java:312)
          at org.apache.catalina.core.StandardWrapper.service(StandardWrapper.java:1523)
          at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:343)
          at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:215)
          at org.primefaces.webapp.filter.FileUploadFilter.doFilter(FileUploadFilter.java:79)
          at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:256)
          at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:215)
          at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:277)
          at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:188)
          at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:641)
          at com.sun.enterprise.web.WebPipeline.invoke(WebPipeline.java:97)
          at com.sun.enterprise.web.PESessionLockingStandardPipeline.invoke(PESessionLockingStandardPipeline.java:85)
          at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:185)
          at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:641)
          at org.apache.catalina.connector.CoyoteAdapter.doService(CoyoteAdapter.java:329)
          at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:233)
          at com.sun.enterprise.v3.services.impl.ContainerMapper.service(ContainerMapper.java:239)
          at com.sun.grizzly.http.ProcessorTask.invokeAdapter(ProcessorTask.java:791)
          at com.sun.grizzly.http.ProcessorTask.doProcess(ProcessorTask.java:693)
          at com.sun.grizzly.http.ProcessorTask.process(ProcessorTask.java:954)
          at com.sun.grizzly.http.DefaultProtocolFilter.execute(DefaultProtocolFilter.java:170)
          at com.sun.grizzly.DefaultProtocolChain.executeProtocolFilter(DefaultProtocolChain.java:135)
          at com.sun.grizzly.DefaultProtocolChain.execute(DefaultProtocolChain.java:102)
          at com.sun.grizzly.DefaultProtocolChain.execute(DefaultProtocolChain.java:88)
          at com.sun.grizzly.http.HttpProtocolChain.execute(HttpProtocolChain.java:76)
          at com.sun.grizzly.ProtocolChainContextTask.doCall(ProtocolChainContextTask.java:53)
          at com.sun.grizzly.SelectionKeyContextTask.call(SelectionKeyContextTask.java:57)
          at com.sun.grizzly.ContextTask.run(ContextTask.java:69)
          at com.sun.grizzly.util.AbstractThreadPool$Worker.doWork(AbstractThreadPool.java:330)
          at com.sun.grizzly.util.AbstractThreadPool$Worker.run(AbstractThreadPool.java:309)
          at java.lang.Thread.run(Thread.java:619)
  Caused by: java.lang.IllegalStateException
          at org.apache.catalina.connector.ResponseFacade.sendError(ResponseFacade.java:486)
          at com.sun.faces.context.ExternalContextImpl.responseSendError(ExternalContextImpl.java:831)
          at javax.faces.context.ExternalContextWrapper.responseSendError(ExternalContextWrapper.java:785)
          at com.sun.faces.application.view.MultiViewHandler.send404Error(MultiViewHandler.java:666)
          at com.sun.faces.application.view.MultiViewHandler.derivePhysicalViewId(MultiViewHandler.java:496)
          at com.sun.faces.application.view.MultiViewHandler.createView(MultiViewHandler.java:160)
          at com.sun.faces.lifecycle.RestoreViewPhase.execute(RestoreViewPhase.java:253)
          at com.sun.faces.lifecycle.Phase.doPhase(Phase.java:101)
          ... 33 more
  </code></pre>
  
  <p>In browser also i see the address :- </p>
  
  <pre><code>http://blogger.blogdns.com:8080/Blogger/;jsessionid=a05bfc017aac39414876eccd38fe
  </code></pre>
  
  <p>No page name(LoginRequestProcessor.jsp), no username, no password.
  Even more interesting is the fact that sometimes it works! But 80% of the time it gives this error and redirects wrongly.</p>
  
  <p>Any ideas how to solve this?</p>
  
  <p><strong>Edit :- if i don't pass jsessionid while redirecting, it works fine but then session id changes. And if i pass jsessionid i get the above error :(.</strong></p>