Wednesday, 6 April 2016

Response has already been commited error. What does it mean ?


This error show only when you try to redirect a page after you already have written something in your page.

This happens because HTTP specification force the header to be set up before the layout of the page can be shown 
(To make sure of how it should be displayed, content-type=”text/html”  or  “text/xml”  or  “plain-text” or “image/jpg”,etc.)

When you try to send a redirect status (Number is line_status_402), your HTTP server cannot send it right now if it hasn’t finished to set up the header. If not started to set up the header, there are no problems, but if it ’s already begin to set up the header, then your HTTP server expects these headers to be finished setting up and it cannot be the case if the stream of the page is not over.

In this last case it’s like you have a file started with <HTMLTag><Some Headers><Body> some output (like testing your variables.)

Before you indicate that the file is over (and before the size of the page can be setted up in the header), you try to send are direct status.
It s simply impossible due to the specification of HTTP 1.0 and 1.1

No comments:

Post a Comment

Note: only a member of this blog may post a comment.