Checking To See If CFFlush Has Already Been Executed Part II

Posted November 3, 2006 at 8:48 AM by Ben Nadel

Tags: ColdFusion

A while back, I posted that you could check to see if CFFlush had been executed earlier in the page processing by trying to set the header and catching any errors that were thrown. This morning, though, I was poking around in ColdFusion's page context (returned via GetPageContext()) and it turns out there is a much more simple way to do this; all you have to do is check to see if the response headers have been committed (written to the output stream):

  • <!--- Check to see if a CFFlush tag has been executed. --->
  • CFFlush: #GetPageContext().GetResponse().IsCommitted()#
  •  
  • <!--- Flush the page. --->
  • <cfflush />
  •  
  • <!--- Check to see if a CFFlush tag has been executed. --->
  • CFFlush: #GetPageContext().GetResponse().IsCommitted()#

This gives us the output:

No
Yes

That's some easy stuff right there. No, keep in mind, this is not just for the CFFlush tag. This is a general way to see if content has already been sent to the browser.



Reader Comments

Nov 3, 2006 at 9:28 AM // reply »
111 Comments

Hey Ben,

Just general comment (not post specific). Lots of very cool posts - really enjoying all this. I notice Andy's linking to some of your posts too for the Scottish CFUG guys (and others) at http://www.creative-restraint.co.uk/blog/index.cfm/2006/11/3/Weekly-Blog-Round-Up.

One small thing - bennadel.com works, but www.bennadel.com doesn't. Any way you could fix the DNS and/or host headers so you allow both (or set up a redirect)?


Nov 3, 2006 at 11:31 AM // reply »
11,238 Comments

Pete,

Thanks for the heads up on the www issue. I have to say that both work for me. But, I talked to one of my more server-savvy co-workers and he says that while all the server stuff is set up to handle it, there is a chance IIS doesn't have it correct. We are waiting for our production box login (from my boss) and we will check the host headers.

I of course know nothing about all this jazz :)

Glad you are enjoying the posts. I am working my way through posts right now. I unfortuantely cannot contribute opinions regarding DAO vs. Gateways cause I don't know that stuff yet... but hopefully I will soon.


Nov 3, 2006 at 12:29 PM // reply »
11,238 Comments

Pete,

The server guys here tell me there is no reason that www.bennadel.com should not be working. Do you have any suggestions?


Nov 3, 2006 at 1:27 PM // reply »
92 Comments

No trouble here viewing your site with www. infront of the domain name. A great post. I've seen the same implemented in the index.cfm of cfwheels (but for a different purpose than cfflush but still deals with output to the browser) and currently use it myself for something new I built. Comes in handy.


Nov 3, 2006 at 1:51 PM // reply »
111 Comments

Ooops - sorry having u chase round Ben - my bad.

Did a link in a comment to your site and had a period in the URL so it was www.bennadel.com. that didn't work (trailing period). Sorry about that! I've just been caught out by the www thing back when I first started admin'ing my sites and I jumped to the (wrong) conclusion.

Say sorry to the server guy for me!


Nov 3, 2006 at 3:19 PM // reply »
11,238 Comments

No worries :) The server guy has to earn his keep ;)


Post A Comment

Comment Etiquette: Please do not post spam. Please keep the comments on-topic. Please do not post unrelated questions or large chunks of code. And, above all, please be nice to each other - we're trying to have a good conversation here.

Please review the following issues:

Author Name:


Author Email:

Author Website:

Comment:

Supported HTML tags for formatting: <strong>bold</strong>   <em>italic</em>   <code>code</code>







  • Help Wanted - Find Your Next ColdFusion Job
Ben Nadel's Company - Epicenter Consulting Recent Blog Comments
May 20, 2013 at 4:38 PM
Using A Dynamic Column Name With ValueList() In ColdFusion
@Dana, Your confusion is well founded, since this is a very confusing features. In fact, it ONLY works if you use array notation. Meaning, that this: arrayToList( query[ "columnName" ] ) ... read »
May 20, 2013 at 4:34 PM
Using A Dynamic Column Name With ValueList() In ColdFusion
I was thinking chicken and the egg, I wouldn't have expected it to work in the valuelist going in I guess. Maybe I just need a beer, long day :) ... read »
May 20, 2013 at 4:29 PM
Using A Dynamic Column Name With ValueList() In ColdFusion
@Dana, That's if you're trying to reference a specific row. In this case, we're trying to reference the entire query column as one cohesive value. So, you are correct that if you wanted to output a ... read »
May 20, 2013 at 4:24 PM
Using A Dynamic Column Name With ValueList() In ColdFusion
I thought when you used array notation to reference queries you always had to have the row or it would throw a similar error as well? ... read »
May 20, 2013 at 11:45 AM
Using jQuery's Animate() Step Callback Function To Create Custom Animations
This is really useful. I found out that you don't actually have to use a dummy css property (surprisingly). To animate a property in a linear-gradient for instance I did this this.css('someLinearGra ... read »
May 20, 2013 at 10:51 AM
Using A Dynamic Column Name With ValueList() In ColdFusion
@Josh, Oh snap! You're totally right! I'm not sure I've ever tried that. I did know that you can call a number of other array-methods on ColdFusion query columns: http://www.bennadel.com/blog/167 ... read »
May 20, 2013 at 10:45 AM
Using A Dynamic Column Name With ValueList() In ColdFusion
@Ben - I believe you can achieve the same functionality with ColdFusion's built in ArrayToList() function. ArrayToList( users[ "id" ] ); ... read »
May 20, 2013 at 10:21 AM
My Experience With AngularJS - The Super-heroic JavaScript MVW Framework
Is there any error logging and handling framework in angularjs, if not then in what way I can do this. ... read »
InVision App - Prototyping Made Beautiful With Prototyping Tools