• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

ColdFusion 2018 onRequestEnd CFOutput issue

New Here ,
Oct 11, 2022 Oct 11, 2022

Copy link to clipboard

Copied

When I try to get a page content by getPageContext().getCFOutput().getString() in onRequestEnd event, I get an empty string.

When I try to get a page content at the end of cfm script by the same code, I get what I expect: not empty content.

Application.cfc:

...

 

<cffunction name="onRequestEnd" output="false" returntype="void" >
    <cfargument type="String" name="targetPage" required=true />

    <cfdump var="getPageContext().getCFOutput().getString() in onRequestEnd: [#getPageContext().getCFOutput().getString()#]" output="C:\debug\debug_test_log.html" format="html" />
</cffunction>

 

...

test.cfm:

 

 

blah blah blah
<cfdump var="getPageContext().getCFOutput().getString() in test.cfm: [#getPageContext().getCFOutput().getString()#]" output="C:\debug\debug_test_log.html" format="html" />

 

 

The debug output (dumped into file) is following:

getPageContext().getCFOutput().getString() in test.cfm: [blah blah blah ]
getPageContext().getCFOutput().getString() in onRequestEnd: []

 

Any idea why it is empty in onRequestEnd event?

I remember it was working as expected in previous CF server versions and I was able to modify or cache an output before sending to a client.

 
 

 

 

Views

131

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Oct 13, 2022 Oct 13, 2022

Copy link to clipboard

Copied

The cfdump tag in test.cfm might be messing things up for you.

Comment it out and see whether that helps.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Oct 13, 2022 Oct 13, 2022

Copy link to clipboard

Copied

quote

The cfdump tag in test.cfm might be messing things up for you.

Comment it out and see whether that helps.


By @BKBK

 

What I mean is, try something like:

<cfoutput>blah blah blah</cfoutput>

<!---
<cfdump etc.>
--->

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Oct 13, 2022 Oct 13, 2022

Copy link to clipboard

Copied

BKBK, thank you for your response!

cfdump tag in test.cfm doesn't affect, I checked.

What I found is output="false" parameter in onRequestEnd function. It does affect.

If I change it to output="true" or omit it entirely, it starts working fine, I get the output content.

In case of output="true" it dumps the content generated only inside onRequestEnd function and ignores the output from test.cfm file.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Oct 13, 2022 Oct 13, 2022

Copy link to clipboard

Copied

Sorry, typo... Should be:

In case of output="false" it dumps the content generated only inside onRequestEnd function and ignores the output from test.cfm file.

 
 

 

 

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Oct 13, 2022 Oct 13, 2022

Copy link to clipboard

Copied

And if bkbk's helpful idea doesn't pan out, another sanity check would be to create a new folder, with that test page (doing absolutely nothing but that blah blah, before or after), and an Application.cfc doing also nothing but that onrequestend method (and not extending any other cfc). Does the function still fail to produce any result?

 

If that works, then clearly something else in your app.cfc (or any you extend/inherit from) or something in your test cfm is impacting your first efforts.

 

If that's the case (or if it fails to work also in this other test), what if you wrap the blah blah in a cfoutput? Not that you should have to, but does it make any difference? Just tossing out diagnostics to try, not solutions for now. 


/Charlie (troubleshooter, carehart.org)

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Oct 13, 2022 Oct 13, 2022

Copy link to clipboard

Copied

It was output="false" parameter in OnRequestEnd

Once I change it to output="true" or omit it entirely, it resolves the issue.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Oct 13, 2022 Oct 13, 2022

Copy link to clipboard

Copied

quote

It was output="false" parameter in OnRequestEnd

 

By @sergey_croitor

 

What's in a name!

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Oct 13, 2022 Oct 13, 2022

Copy link to clipboard

Copied

In case of output="false" in onRequestEnd it dumps the content generated only inside onRequestEnd function and ignores the output from test.cfm file.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Oct 13, 2022 Oct 13, 2022

Copy link to clipboard

Copied

And thank you for your response, Charlie!

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Oct 13, 2022 Oct 13, 2022

Copy link to clipboard

Copied

Deleted

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Oct 13, 2022 Oct 13, 2022

Copy link to clipboard

Copied

Sorry, @Charlie Arehart and @sergey_croitor. My forum page didn't refresh. So I missed your your recent posts. Please, ignore what I said. 

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Oct 13, 2022 Oct 13, 2022

Copy link to clipboard

Copied

onRequestEnd.png

@BKBK, in my case the highlighted parameter was the reason of issue. Do you have it defined in your onRequestEnd?

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Oct 13, 2022 Oct 13, 2022

Copy link to clipboard

Copied

FWIW, I had noticed that, but since you were doing a cfdump to a file, I presumed it may not impact. But are you saying even with that false, and a cfoutput around your blah blah, the it still didn't dump anything (from within that onrequestend)? 


/Charlie (troubleshooter, carehart.org)

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Oct 13, 2022 Oct 13, 2022

Copy link to clipboard

Copied

LATEST

@Charlie Arehart, with output="false" it dumps only what is inside OnRequestEnd. It ignores the content from test.cfm. In browser I see the opposite: the content from test.cfm only, without the content from onRequestEnd.

A bit confusing  🙂 Anyway output="true" resolves my issue.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Resources
Documentation