0

I'm using Primefaces 4.0 + JSF 2.1 + Bootstrap 3 and when I try put "h:form" in block bellow I got a error:

Caused by: java.lang.IllegalStateException: Cannot create a session after the response has been committed

So, this code bellow throws the error above:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
    xmlns:h="http://java.sun.com/jsf/html"
    xmlns:f="http://java.sun.com/jsf/core"
    xmlns:ui="http://java.sun.com/jsf/facelets"
    xmlns:p="http://primefaces.org/ui">

<h:head />
<h:body>
    <ui:composition template="/templates/template.xhtml">
        <ui:define name="content">
            <h:form>
             hello world
            </h:form>
        </ui:define>
    </ui:composition>
</h:body>
</html>

If I remove the "h:form" the 'hello world' is rendered.

I tried this is my web.xml, but didn't work too:

<context-param>   
<param-name>
    com.sun.faces.writeStateAtFormEnd</param-name>   
<param-value>false</param-value>   
</context-param>
BalusC
  • 1,082,665
  • 372
  • 3,610
  • 3,555
Shelly
  • 1,035
  • 5
  • 27
  • 51
  • 2
    http://stackoverflow.com/a/8072445/1391249 – Tiny Jan 27 '15 at 11:31
  • Thanks, it's work. I created a filter and use getSession(). – Shelly Jan 27 '15 at 13:25
  • Instead if you had upgraded the Mojarra version itself, wouldn't it have been better? (If you were open to change software components in your project). – Tiny Jan 27 '15 at 15:25
  • I already upgraded to JSF 2.2 – Shelly Jan 27 '15 at 19:45
  • Is it still be produced in JSF 2.2? The duplicate question link indicates that it was fixed in Mojarra 2.1.8. So, there should not be a need to play some extra tricks to make it work. Shouldn't it? (I myself did not ever meet with this exception in a scenario given and therefore, I cannot justify it). – Tiny Jan 28 '15 at 00:04
  • I don't know why but when i enabled my "LoginFIlter' everything works, if i disable the error occurr – Shelly Jan 28 '15 at 01:59

0 Answers0