Reputation: 51146
I'm looking for something like Response.Clear()
.
Upvotes: 8
Views: 5567
Reputation: 80966
The two existing answers (<cfset GetPageContext().getCFOutput().clear()>
and <cfcontent reset="true">
) will reset the main content buffer, but those commands will not reset the header buffers (i.e. content that ColdFusion automatically inserts into the <head>
element such as <script>
tags when using <cfchart>
).
To reset everything, you can use either of the following approaches:
<cfcontent reset="true" resethead="true">
or
<cfset getPageContext().getCFOutput().clearAll()>
<cfset getPageContext().getCFOutput().clearHeaderBuffers()>
These approaches are not documented (so possible to change in future version -- though unlikely) and these approaches are unlikely to be portable to other CFML engines, but I have not found any documented approach for clearing the header buffers.
Related answer: Is there a way to prevent cfchart from forcing js into response content?
Upvotes: 0
Reputation: 10627
You can reset the output buffer using the cfcontent tag with the reset argument:
<cfcontent reset="true">
Upvotes: 29
Reputation: 2895
This will clear the response body and prevent the output of buffered content -
<cfset GetPageContext().getCFOutput().clear()>
Upvotes: 12