Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

cf10 unable to add text to HTML Head

I am getting the following error on a page we are loading:

coldfusion.runtime.CfErrorWrapper 
Unable to add text to HTML HEAD tag. 
[empty string] 

caused by

Template

Unable to add text to HTML HEAD tag. 
ColdFusion was unable to add the text you specified to the output stream. This is probably because you have already used a CFFLUSH tag in your template or buffered output is turned off.

I've done a sweep of all the files that are included in our application and cannot find anything that uses CFFlush.

output is set to 'no' on all cfcs and components. I also tried adding cfsetting showdebugoutput = no in a file. That didn't help.

I turned request debugging on in cfadmin and that didn't help.

The HTML Head works fine in other parts of our app, it just seems to be on this one page.

The only thing really different about this page is that it is a particularly long page.

like image 572
Rumpleteaser Avatar asked Jul 07 '13 21:07

Rumpleteaser


2 Answers

If it's a particularly long page, then CF may be flushing the buffer on its own. If you check in the CFAdmin, on the settings page, there is a setting for Maximum Output Buffer size. I believe the default is 1024 KB. If your page is over 1 meg of content, then CF may flush the buffer before your <cfhtmlhead /> tag runs. Try increasing the buffer size, or changing the placement of the <cfhtmlhead /> tag to see if that corrects the issue.

like image 122
Dan Short Avatar answered Oct 20 '22 04:10

Dan Short


I've run into the same problem recently but the behavior wasn't predictable. I believe that Dan Short's answer is correct. I created some test pages to see if I could reproduce the problem. Each time TestTemplate.cfm is included, CFHTMLHEAD writes a simple JavaScript alert to the head tag. Once the buffer is reached, and the page is automatically flushed, any subsequent CFHTMLHEAD tag use will result in an error, specifically, the error in the original post. As Dan indicates, you can work your way around this issue by changing the maximum output buffer size.

file: index.cfm

<html>
<head><title>Test Page</title></head>
<body>
<cfset SampleScript = "<script src='sample.js'></script>"> 
cfset Count = 0>
<cfinclude template="TestTemplate.cfm"> 
<cfinclude template="TestTemplate.cfm"> 
<cfinclude template="TestTemplate.cfm"> 
</body>
</html>

file TestTemplate.cfm

<cfhtmlhead text="#SampleScript#">
<cfset Count++>
<cfoutput>
<h1>Count #Count#</h1>
</cfoutput>

<cfoutput>
<cfloop from="1" to="100000" index="i">
    <cfscript>
    j = randRange(i, 1000000);
    k = randRange(i, 1000000);
    l = j * k;
    writeOutput(l);
</cfscript> 
</cfloop>
</cfoutput>

file sample.js

alert('Boo!');
like image 29
Evik James Avatar answered Oct 20 '22 04:10

Evik James