Uploaded image for project: 'Magnolia'
  1. Magnolia
  2. MAGNOLIA-3984

A way to prevent "Cannot create a session after the response has been committed"

XMLWordPrintable

    • Icon: Improvement Improvement
    • Resolution: Won't Fix
    • Icon: Neutral Neutral
    • None
    • 4.4.5
    • core
    • JBoss 5.1 EAP, Oracle 10, Google Chrome 17.0.963.56, Firefox 10.0.1, Ubuntu 11.10

      Hi,

      Me and my team noticed a very interesting behavior for one of our Spring Webflow components. For some of our browsers it generated the exception: "java.lang.IllegalStateException: Cannot create a session after the response has been committed". This seems to be because the template html is being written to the request output stream before any of our components. When Magnolia iterates and executes our Spring Webflow component it tries to create a session, which by then is too late because data is already being written to the output stream. Although this is only a problem if the end-users browser doesn't support G-Zip and if the cache filter is disabled for a specific path. The supplied browser versions (and OS version) I've supplied above seems to not accept G-zip content which is why I notice this behavior on my computer.

      So my proposal is this: Is it possible for you to use a separate OutputStream instance and then write to the real OutputStream when the entire template/page is rendered? We are adding "<#assign session = ${ctx.request.session} />" at the top of the freemarker template file as a workaround at the moment.

      Used this forum-post as a reference: http://forum.magnolia-cms.com/forum/thread.html?threadId=5e34ed28-5269-4333-9e9d-a30aca8a95e3

        Acceptance criteria

              tmattsson Tobias Mattsson
              pean56 Per Andersson [X] (Inactive)
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

                Created:
                Updated:
                Resolved:

                  Task DoD