ColdFusion – How do I retrieve the current value of EnablecfoutPutonly?

We are using Coldfusion 9.

Is there an easy way to know if enablecfoutputonly has been set to true during a particular request?

I cannot use CF9 for testing now, but in CF10, you can check the output object from getPageContext ()Access it:


out = getPageContext().getOut();
// Is the cfsetting enablecfoutputonly value currently true?
isSettingEnabled = out.getDisableCount()> 0;
WriteOutput("isSettingEnabled="& isSettingEnabled &"
");
// Is output currently allowed?
isOuputtingEnabled = out.getDisableCount() == 0 || out.getOutputCount()> 0;
WriteOutput("isOuputtingEnabled="& isOuputtingEnabled &"
");

.. Or use reflection:


out = getPageContext().getOut();
internalMethod = out.getClass().getDeclaredMethod("isOutputEnabled", []);
internalMethod.setAccessible( true );
isOuputtingEnabled = internalMethod.invoke( out, [] );
// is output currently allowed?
WriteOutput("isOuputtingEnabled="& isOuputtingEnabled);

We are using Coldfusion 9.

Is there an easy way to know if enablecfoutputonly has been enabled during a specific request? Set to true?

I cannot use CF9 for testing now, but in CF10, it can be accessed from getPageContext() by checking the output object:


out = getPageContext().getOut();
// Is the cfsetting enablecfoutputonly value currently true?
isSettingEnabled = out.getDisableCount ()> 0;
WriteOutput("isSettingEnabled="& isSettingEnabled &"
");
// Is output currently allowed?
isOuputtingEnabled = out.getDisableCount() == 0 || out.getOutputCount()> 0;
WriteOutput("isOuputtingEnabled="& isOuputtingEnabled &"
");

.. or use reflection :


out = getPageContext().getOut();
internalMethod = out.getClass().getDeclaredMethod("isOutputEnabled", []);
internalMethod.setAccessible( true );
isOuputtingEnabled = internalMethod.invoke( out, [] );
// is output currently allowed?
WriteOutput("isOuputtingEnabled ="& isOuputtingEnabled);

Leave a Comment

Your email address will not be published.