title: cannot create session after response has been committed
body: <p>i am getting the following error on my application startup page load :   </p>
  
  <pre><code> SEVERE: Error Rendering View[/HomeTemplate/equityVolume.xhtml]
  javax.el.ELException: /HomeTemplate/equityVolume.xhtml @70,78 value="#{equityBean.scripList}": java.lang.IllegalStateException: PWC3999: Cannot create a session after the response has been committed...
  
      Caused by: java.lang.IllegalStateException: PWC3999: Cannot create a session after the response has been committed...
  </code></pre>
  
  <p>i get this error when i apply the css to my homepage, the error disappears when i remove the css template(but i want to aplly the css template)
  following is the bean code snippet that causes the error(found by debugging)</p>
  
  <pre><code>public List&lt;MasterScrip&gt; getScripList() {
     HttpServletRequest req=(HttpServletRequest)FacesContext.getCurrentInstance().getExternalContext().getRequest(); //error line
     HttpSession session=req.getSession();
     type=(String)session.getAttribute("type");...
  </code></pre>
  
  <p>xhtml code:</p>
  
  <pre><code>&lt;h:body&gt;
      &lt;ui:composition template="commonClientLayout.xhtml"&gt;
  
      &lt;ui:define name="contentFile"&gt;
              &lt;div id="content"&gt;
      &lt;h:form id="frm"&gt;...
  </code></pre>
  
  <p>when i remove the ui:composition and define tags(i.e. if i dont apply the css), then i dont get this error.
  what could be causing this error and how do i solve it?</p>
  
  <p><strong>edited:</strong></p>
  
  <pre><code>    @PostConstruct
  void initialiseSession() {
      if(type!=null)
        {
         if(type.equalsIgnoreCase("losers"))
         {
          scripList=new ArrayList&lt;MasterScrip&gt; ();
          scripList=getScripByPriceLosers(exchange);
         // return scripList;
         }
         else if(type.equalsIgnoreCase("gainers"))
         {
          scripList=new ArrayList&lt;MasterScrip&gt; ();
       scripList=getScripByPriceGainers(exchange);
         // return scripList;
         }
         else
         {
             scripList=new ArrayList&lt;MasterScrip&gt; ();
       scripList=getScripByVolumeType(exchange);
       //  return scripList;
         }
        }
        else
        {
            scripList=new ArrayList&lt;MasterScrip&gt; ();
       scripList=getScripByVolumeType(exchange);
        }
  
  }
  
      public List&lt;MasterScrip&gt; getScripList() {
         return scripList;
  
      }
  </code></pre>
  
  <p><strong>edited again:</strong>   </p>
  
  <pre><code> SEVERE: Error Rendering View[/equityVolume.xhtml]
  java.lang.IllegalStateException
      at org.apache.catalina.connector.ResponseFacade.setBufferSize(ResponseFacade.java:275)...
  </code></pre>
  
  <p><em><strong>edit: web.xml</em></strong></p>
  
  <pre><code>    &lt;?xml version="1.0" encoding="UTF-8"?&gt;
  &lt;web-app version="3.0" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd"&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.FACELETS_BUFFER_SIZE&lt;/param-name&gt;
          &lt;param-value&gt;65535&lt;/param-value&gt;
      &lt;/context-param&gt;
  
      &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;*.xhtml&lt;/url-pattern&gt;
      &lt;/servlet-mapping&gt;
      &lt;session-config&gt;
          &lt;session-timeout&gt;
              30
          &lt;/session-timeout&gt;
  
      &lt;/session-config&gt;
      &lt;welcome-file-list&gt;
          &lt;welcome-file&gt;equityVolume.xhtml&lt;/welcome-file&gt;
      &lt;/welcome-file-list&gt;
      &lt;security-constraint&gt;
          &lt;display-name&gt;Constraint1&lt;/display-name&gt;
          &lt;web-resource-collection&gt;
              &lt;web-resource-name&gt;AdminTemplate&lt;/web-resource-name&gt;
              &lt;description/&gt;
              &lt;url-pattern&gt;/AdminTemplate/*&lt;/url-pattern&gt;
          &lt;/web-resource-collection&gt;
          &lt;auth-constraint&gt;
              &lt;description/&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;Constraint2&lt;/display-name&gt;
          &lt;web-resource-collection&gt;
              &lt;web-resource-name&gt;ClientTemplate&lt;/web-resource-name&gt;
              &lt;description/&gt;
              &lt;url-pattern&gt;/ClientTemplate/*&lt;/url-pattern&gt;
          &lt;/web-resource-collection&gt;
          &lt;auth-constraint&gt;
              &lt;description/&gt;
              &lt;role-name&gt;client&lt;/role-name&gt;
          &lt;/auth-constraint&gt;
      &lt;/security-constraint&gt;
      &lt;login-config&gt;
          &lt;auth-method&gt;FORM&lt;/auth-method&gt;
          &lt;realm-name&gt;DataRealm&lt;/realm-name&gt;
          &lt;form-login-config&gt;
              &lt;form-login-page&gt;/equityVolume.xhtml&lt;/form-login-page&gt;
              &lt;form-error-page&gt;/errorpage.xhtml&lt;/form-error-page&gt;
          &lt;/form-login-config&gt;
      &lt;/login-config&gt;
      &lt;security-role&gt;
          &lt;description/&gt;
          &lt;role-name&gt;admin&lt;/role-name&gt;
      &lt;/security-role&gt;
      &lt;security-role&gt;
          &lt;description/&gt;
          &lt;role-name&gt;client&lt;/role-name&gt;
      &lt;/security-role&gt;
  &lt;/web-app&gt;
  </code></pre>