- CFML Reference User Guide
- ColdFusion functions
- ColdFusion functions by category
- Functions a-b
- Abs
- ACos
- AddSOAPRequestHeader
- AddSOAPResponseHeader
- AjaxLink
- AjaxOnLoad
- ApplicationStop
- ArrayAppend
- ArrayAvg
- ArrayClear
- ArrayContains
- ArrayContainsNoCase
- ArrayDelete
- ArrayDeleteAt
- ArrayDeleteNoCase
- ArrayEach
- ArrayFilter
- ArrayFind
- ArrayFindAll
- ArrayFindAllNoCase
- ArrayFindNoCase
- ArrayInsertAt
- ArrayIsDefined
- ArrayIsEmpty
- ArrayLen
- ArrayMap
- ArrayMax
- ArrayMin
- ArrayNew
- ArrayPrepend
- ArrayReduce
- ArrayResize
- ArraySet
- ArraySetMetadata
- ArraySlice
- ArraySort
- ArraySum
- ArraySwap
- ArrayToList
- Asc
- ASin
- Atn
- AuthenticatedContext
- AuthenticatedUser
- BinaryDecode
- BinaryEncode
- BitAnd
- BitMaskClear
- BitMaskRead
- BitMaskSet
- BitNot
- BitOr
- BitSHLN
- BitSHRN
- BitXor
- BooleanFormat
- Abs
- Functions-c-d
- CacheGet
- CacheGetAllIds
- CacheGetMetadata
- CacheGetProperties
- CacheGetSession
- CacheIdExists
- CachePut
- CacheRegionExists
- CacheRegionNew
- CacheRegionRemove
- CacheRemove
- CacheRemoveAll
- CacheSetProperties
- CallStackDump
- CallStackGet
- CanDeSerialize
- Canonicalize
- CanSerialize
- Ceiling
- CharsetDecode
- CharsetEncode
- Chr
- CJustify
- Compare
- CompareNoCase
- Cos
- CreateDate
- CreateDateTime
- CreateObject
- CreateObject: .NET object
- CreateObject: COM object
- CreateObject: component object
- CreateObject: CORBA object
- CreateObject: Java or EJB object
- CreateObject: web service object
- CreateODBCDate
- CreateODBCDateTime
- CreateODBCTime
- CreateSignedJWT
- CreateEncryptedJWT
- CreateTime
- CreateTimeSpan
- CreateUUID
- CSRFGenerateToken
- CSRFVerifyToken
- CSVRead
- CSVWrite
- CSVProcess
- DateAdd
- DateCompare
- DateConvert
- DateDiff
- DateFormat
- DatePart
- DateTimeFormat
- Day
- DayOfWeek
- DayOfWeekAsString
- DayOfYear
- DaysInMonth
- DaysInYear
- DE
- DecimalFormat
- DecodeForHTML
- DecodeFromURL
- DecrementValue
- Decrypt
- DecryptBinary
- DeleteClientVariable
- Deserialize
- DeserializeJSON
- DeserializeXML
- DirectoryCopy
- DirectoryCreate
- DirectoryDelete
- DirectoryExists
- DirectoryList
- DirectoryRename
- DollarFormat
- DotNetToCFType
- Duplicate
- Functions-e-g
- EncodeForCSS
- EncodeForDN
- EncodeForHTML
- EncodeForHTMLAttribute
- EncodeForJavaScript
- EncodeForLDAP
- EncodeForURL
- EncodeForXML
- EncodeForXMLAttribute
- EncodeForXpath
- Encrypt
- EncryptBinary
- EntityDelete
- EntityLoad
- EntityLoadByExample
- EntityLoadByPK
- EntityMerge
- EntityNew
- EntityReload
- EntitySave
- EntityToQuery
- Evaluate
- Exp
- ExpandPath
- FileClose
- FileCopy
- FileDelete
- FileExists
- FileGetMimeType
- FileIsEOF
- FileMove
- FileOpen
- FileRead
- FileReadBinary
- FileReadLine
- FileSeek
- FileSetAccessMode
- FileSetAttribute
- FileSetLastModified
- FileSkipBytes
- FileUpload
- FileUploadAll
- FileWrite
- FileWriteLine
- Find
- FindNoCase
- FindOneOf
- FirstDayOfMonth
- Fix
- Floor
- FormatBaseN
- GeneratePBKDFKey
- GenerateSecretKey
- GetApplicationMetadata
- GetAuthUser
- GetBaseTagData
- GetBaseTagList
- GetBaseTemplatePath
- GetClientVariablesList
- GetComponentMetaData
- GetContextRoot
- GetCPUUsage
- GetCurrentTemplatePath
- GetCSPNonce
- GetDirectoryFromPath
- GetEncoding
- GetException
- GetFileFromPath
- GetFileInfo
- GetFreeSpace
- GetFunctionCalledName
- GetFunctionList
- GetGatewayHelper
- GetHttpRequestData
- GetHttpTimeString
- GetK2ServerDocCount
- GetK2ServerDocCountLimit
- GetLocale
- GetLocaleDisplayName
- GetLocalHostIP
- GetMetaData
- GetMetricData
- GetPageContext
- GetPropertyString
- GetPropertyFile
- GetPrinterInfo
- GetPrinterList
- GetProfileSections
- GetProfileString
- GetReadableImageFormats
- GetSafeHTML
- GetSAMLAuthRequest
- GetSAMLLogoutRequest
- Generate3DesKey
- GenerateSAMLSPMetadata
- GetSOAPRequest
- GetSOAPRequestHeader
- GetSOAPResponse
- GetSOAPResponseHeader
- GetSystemFreeMemory
- GetSystemTotalMemory
- GetTempDirectory
- GetTempFile
- GetTemplatePath
- GetTickCount
- GetTimeZoneInfo
- GetToken
- GetTotalSpace
- GetUserRoles
- GetVFSMetaData
- GetWriteableImageFormats
- Functions-h-im
- Hash
- HMac
- Hour
- HQLMethods
- HTMLCodeFormat
- HTMLEditFormat
- IIf
- ImageAddBorder
- ImageBlur
- ImageClearRect
- ImageCopy
- ImageCreateCaptcha
- ImageCrop
- ImageDrawArc
- ImageDrawBeveledRect
- ImageDrawCubicCurve
- ImageDrawLine
- ImageDrawLines
- ImageDrawOval
- ImageDrawPoint
- ImageDrawQuadraticCurve
- ImageDrawRect
- ImageDrawRoundRect
- ImageDrawText
- ImageFlip
- ImageGetBlob
- ImageGetBufferedImage
- ImageGetEXIFMetadata
- ImageGetEXIFTag
- ImageGetHeight
- ImageGetIPTCMetadata
- ImageGetIPTCTag
- ImageGetMetadata
- ImageGetWidth
- ImageGrayscale
- ImageInfo
- ImageMakeColorTransparent
- ImageMakeTranslucent
- ImageNegative
- ImageNew
- ImageOverlay
- ImagePaste
- ImageRead
- ImageReadBase64
- ImageResize
- ImageRotate
- ImageRotateDrawingAxis
- ImageScaleToFit
- ImageSetAntialiasing
- ImageSetBackgroundColor
- ImageSetDrawingColor
- ImageSetDrawingStroke
- ImageSetDrawingTransparency
- ImageSharpen
- ImageShear
- ImageShearDrawingAxis
- ImageTranslate
- ImageTranslateDrawingAxis
- ImageWrite
- ImageWriteBase64
- ImageXORDrawingMode
- Functions-in-k
- IncrementValue
- InputBaseN
- Insert
- Int
- InterruptThread
- InvalidateOauthAccesstoken
- Invoke
- InitSAMLAuthRequest
- InitSAMLLogoutRequest
- InvokeCFClientFunction
- IsArray
- IsAuthenticated
- IsAuthorized
- IsBinary
- IsBoolean
- IsClosure
- IsCustomFunction
- IsDate
- IsDateObject
- IsDDX
- IsDebugMode
- IsDefined
- IsImage
- IsImageFile
- IsInstanceOf
- IsIPv6
- IsJSON
- IsK2ServerABroker
- IsK2ServerDocCountExceeded
- IsK2ServerOnline
- IsLeapYear
- IsLocalHost
- IsNull
- IsNumeric
- IsNumericDate
- IsObject
- isOnline
- IsPDFArchive
- IsPDFFile
- IsPDFObject
- IsProtected
- IsQuery
- isSamlLogoutResponse
- isSafeHTML
- IsSimpleValue
- IsSOAPRequest
- IsSpreadsheetFile
- IsSpreadsheetObject
- IsStruct
- isThreadInterrupted
- IsUserInAnyRole
- IsUserInRole
- IsUserLoggedIn
- IsValid
- IsValidOauthAccesstoken
- IsWDDX
- IsXML
- IsXmlAttribute
- IsXmlDoc
- IsXmlElem
- IsXmlNode
- IsXmlRoot
- JavaCast
- JSStringFormat
- Functions-l
- LCase
- Left
- Len
- ListAppend
- ListChangeDelims
- ListContains
- ListContainsNoCase
- ListDeleteAt
- ListEach
- ListFilter
- ListFind
- ListFindNoCase
- ListFirst
- ListGetAt
- ListGetDuplicates
- ListInsertAt
- ListLast
- ListLen
- ListMap
- ListPrepend
- ListQualify
- ListReduce
- ListRemoveDuplicates
- ListRest
- ListSetAt
- ListSort
- ListToArray
- ListValueCount
- ListValueCountNoCase
- LJustify
- Location
- Log
- Log10
- LSCurrencyFormat
- LSDateFormat
- LSDateTimeFormat
- LSEuroCurrencyFormat
- LSIsCurrency
- LSIsDate
- LSIsNumeric
- LSNumberFormat
- LSParseCurrency
- LSParseDateTime
- LSParseEuroCurrency
- LSParseNumber
- LSTimeFormat
- LTrim
- Functions-m-r
- Max
- Mid
- Min
- Minute
- Month
- MonthAsString
- Now
- NumberFormat
- ObjectEquals
- ObjectLoad
- ObjectSave
- OnWSAuthenticate
- ORMClearSession
- ORMCloseAllSessions
- ORMCloseSession
- ORMEvictCollection
- ORMEvictEntity
- ORMEvictQueries
- ORMExecuteQuery
- ORMFlush
- ORMFlushall
- ORMGetSession
- ORMGetSessionFactory
- ORMIndex
- ORMIndexPurge
- ORMReload
- ORMSearch
- ORMSearchOffline
- ParagraphFormat
- ParameterExists
- ParseDateTime
- Pi
- PrecisionEvaluate
- ProcessSAMLResponse
- ProcessSAMLLogoutRequest
- Quarter
- PreserveSingleQuotes
- QueryAddColumn
- QueryAddRow
- QueryConvertForGrid
- QueryExecute
- QueryFilter
- QueryGetResult
- QueryGetRow
- QueryKeyExists
- QueryMap
- QueryNew
- QueryReduce
- QuerySetCell
- QuotedValueList
- QueryEach
- Rand
- Randomize
- RandRange
- ReEscape
- REFind
- REFindNoCase
- ReleaseComObject
- REMatch
- REMatchNoCase
- RemoveCachedQuery
- RemoveChars
- RepeatString
- Replace
- ReplaceList
- ReplaceNoCase
- REReplace
- REReplaceNoCase
- RestDeleteApplication
- RestSetResponse
- RestInitApplication
- Reverse
- Right
- RJustify
- Round
- RTrim
- Functions-s
- Second
- SendGatewayMessage
- SendSAMLLogoutResponse
- Serialize
- SerializeJSON
- SerializeXML
- SessionInvalidate
- SessionRotate
- SessionGetMetaData
- SessionInvalidate
- SessionRotate
- SetDay
- SetEncoding
- SetHour
- SetLocale
- SetMonth
- SetProfileString
- SetPropertyString
- SetVariable
- SetYear
- Sgn
- Sin
- Sleep
- SpanExcluding
- SpanIncluding
- SpreadsheetAddAutoFilter
- SpreadsheetAddColumn
- SpreadsheetAddFreezePane
- SpreadsheetAddImage
- SpreadsheetAddInfo
- SpreadsheetAddPageBreaks
- SpreadsheetAddRow
- SpreadsheetAddRows
- SpreadsheetAddSplitPane
- SpreadsheetCreateSheet
- SpreadsheetDeleteColumn
- SpreadsheetDeleteColumns
- SpreadsheetDeleteRow
- SpreadsheetDeleteRows
- SpreadsheetFormatCell
- SpreadsheetFormatColumn
- SpreadsheetFormatCellRange
- SpreadsheetFormatColumn
- SpreadsheetFormatColumns
- SpreadsheetFormatRow
- SpreadsheetFormatRows
- SpreadsheetGetCellComment
- SpreadsheetGetCellFormula
- SpreadsheetGetCellValue
- SpreadsheetGetColumnCount
- SpreadsheetInfo
- SpreadsheetMergeCells
- SpreadsheetNew
- SpreadsheetRead
- SpreadsheetReadBinary
- SpreadsheetRemoveSheet
- SpreadsheetSetActiveSheet
- SpreadsheetSetActiveSheetNumber
- SpreadsheetSetCellComment
- SpreadsheetSetCellFormula
- SpreadsheetSetCellValue
- SpreadsheetSetColumnWidth
- SpreadsheetSetFooter
- SpreadsheetSetHeader
- SpreadsheetSetRowHeight
- SpreadsheetShiftColumns
- SpreadsheetShiftRows
- SpreadsheetWrite
- StreamingSpreadsheetNew
- StreamingSpreadsheetCleanup
- StreamingSpreadsheetRead
- StreamingSpreadsheetProcess
- SpreadsheetSetFooterImage
- SpreadsheetSetHeaderImage
- SpreadsheetSetFittoPage
- SpreadsheetUngroupColumns
- SpreadsheetGroupColumns
- SpreadsheetUngroupRows
- SpreadsheetGroupRows
- SpreadsheetRemoveColumnBreak
- SpreadsheetSetColumnBreak
- SpreadsheetRemoveRowBreak
- SpreadsheetSetRowBreak
- SpreadsheetRemovePrintGridlines
- SpreadsheetAddPrintGridlines
- SpreadsheetGetColumnWidth
- SpreadsheetSetColumnHidden
- SpreadsheetSetRowHidden
- SpreadsheetisColumnHidden
- SpreadsheetisRowHidden
- SpreadsheetisStreamingXmlFormat
- SpreadsheetisXmlFormat
- SpreadsheetisBinaryFormat
- SpreadsheetRenameSheet
- SpreadsheetRemoveSheetNumber
- SpreadsheetGetLastRowNumber
- SpreadsheetGetPrintOrientation
- Sqr
- StripCR
- StructAppend
- StructClear
- StructCopy
- StructCount
- StructDelete
- StructEach
- StructFilter
- StructFind
- StructFindKey
- StructFindValue
- StructGet
- StructGetMetadata
- StructInsert
- StructIsEmpty
- StructKeyArray
- StructKeyExists
- StructKeyList
- StructMap
- StructNew
- StructReduce
- StructSetMetadata
- StructSort
- StructToSorted
- StructUpdate
- StructValueArray
- StoreSetMetadata
- StoreGetACL
- StoreGetMetadata
- StoreAddACL
- StoreSetACL
- Functions-t-z
- Tan
- ThreadJoin
- ThreadTerminate
- Throw
- TimeFormat
- ToBase64
- ToBinary
- ToScript
- ToString
- Trace
- Transactionandconcurrency
- TransactionCommit
- TransactionRollback
- TransactionSetSavePoint
- Trim
- UCase
- URLDecode
- URLEncodedFormat
- URLSessionFormat
- Val
- ValueList
- VerifyClient
- Week
- Wrap
- WriteDump
- WriteLog
- WriteOutput
- WSGetAllChannels
- WSGetSubscribers
- WSPublish
- WSSendMessage
- XmlChildPos
- XmlElemNew
- XmlFormat
- XmlGetNodeType
- XmlNew
- XmlParse
- XmlSearch
- XmlTransform
- XmlValidate
- Year
- YesNoFormat
- ColdFusion tags
- ColdFusion tag summary
- ColdFusion tags by category
- Application framework tags
- Communications tags
- Database manipulation tags
- Data output tags
- Debugging tags
- Exception handling tags
- Extensibility tags
- File management tags
- Flow-control tags
- Forms tags
- Internet Protocol tags
- Page processing tags
- Security tags
- Variable manipulation tags
- Other tags
- Tags a-b
- Tags c
- cfcache
- cfcalendar
- cfcase
- cfcatch
- cfchart
- cfchart tag in ColdFusion
- Get started with cfchart
- Customize a chart using cfchart
- Advanced cfchart customization options
- Create an area chart in ColdFusion
- Create line charts in ColdFusion
- Create bar charts in ColdFusion
- Create floating bar charts in ColdFusion
- Create histograms in ColdFusion
- Create pie charts in ColdFusion
- Create funnel charts in ColdFusion
- Create pyramid charts in ColdFusion
- Create curve charts in ColdFusion
- Create boxplots in ColdFusion
- Create donut charts in ColdFusion
- Create bubble charts in ColdFusion
- Create scatterplots in ColdFusion
- Create radar charts in ColdFusion
- Other chart types in ColdFusion (Cone, Cylinder, Piano, and Bullet)
- Advanced customization options in cfchart
- cfchartdata
- cfchartseries
- cfchartset
- cfclient
- cfclientsettings
- cfcol
- cfcollection
- cfcomponent
- cfcontent
- cfcontinue
- cfcookie
- Tags f
- cffeed
- cffile
- cffile action = "append"
- cffile action = "copy"
- cffile action = "delete"
- cffile action = "move"
- cffile action = "read"
- cffile action = "readBinary"
- cffile action = "rename"
- cffile action = "upload"
- cffile action = "uploadAll"
- cffile action = "write"
- cffileupload
- cffinally
- cfflush
- cfform
- cfformgroup
- cfformitem
- cfftp
- cfftp: Connection: file and directory operations
- cfftp: Opening and closing FTP server connections
- cfftp : Opening and closing secure FTP server connections
- cfftp action = "listDir"
- cffunction
- Tags g-h
- Tags i
- Tags j-l
- cfjava
- cflayout
- cflayoutarea
- cfldap
- cflocation
- cflock
- cflog
- cflogin
- cfloginuser
- cflogout
- cfloop
- cfloop : conditional loop
- cfloop : index loop
- cfloop : looping over a COM collection or structure
- cfloop : looping over a date or time range
- cfloop : looping over a list, a file, or an array
- cfloop : looping over a query
- Tags m-o
- cfmail
- cfmailparam
- cfmailpart
- cfmap
- cfmapitem
- cfmediaplayer
- cfmenu
- cfmenuitem
- cfmessagebox
- cfmodule
- cfNTauthenticate
- cfoauth
- cfobject
- cfobject: .NET object
- cfobject: COM object
- cfobject: component object
- cfobject: CORBA object
- cfobject: Java or EJB object
- cfobject: web service object
- cfobjectcache
- cfoutput
- Tags p-q
- Tags r-s
- Tags t
- Tags u-z
- CFML Reference
- Reserved words and variables
- Ajax JavaScript functions
- Ajax JavaScript functions
- Function summary Ajax
- ColdFusion.Ajax.submitForm
- ColdFusion.Autosuggest.getAutosuggestObject
- ColdFusion.Layout.enableSourceBind
- ColdFusion.MessageBox.getMessageBoxObject
- ColdFusion.ProgressBar.getProgressBarObject
- ColdFusion.MessageBox.isMessageBoxDefined
- JavaScriptFunctionsinColdFusion9Update1
- ColdFusion ActionScript functions
- ColdFusion mobile functions
- Application.cfc reference
- Script functions implemented as CFCs
- ColdFusion Flash Form style reference
- Styles valid for all controls
- Styles for cfform
- Styles for cfformgroup with horizontal or vertical type attributes
- Styles for box-style cfformgroup elements
- Styles for cfformgroup with accordion type attribute
- Styles for cfformgroup with tabnavigator type attribute
- Styles for cfformitem with hrule or vrule type attributes
- Styles for cfinput with radio, checkbox, button, image, or submit type attributes
- Styles for cftextarea tag and cfinput with text, password, or hidden type attributes
- Styles for cfselect with size attribute value of 1
- Styles for cfselect with size attribute value greater than 1
- Styles for cfcalendar tag and cfinput with dateField type attribute
- Styles for the cfgrid tag
- Styles for the cftree tag
- ColdFusion Flash Form Style Reference
- ColdFusion event gateway reference
- ColdFusion Event Gateway reference
- addEvent
- CFEvent
- CFEventclass
- Constructor
- Gateway development interfaces and classes
- getStatus
- setCFCPath
- setCFCMethod
- getOriginatorID
- getLogger
- getBuddyList
- getBuddyInfo
- IM gateway message sending commands
- IM Gateway GatewayHelper class methods
- onIncomingMessage
- onIMServerMessage
- onBuddyStatus
- onAddBuddyResponse
- onAddBuddyRequest
- IM Gateway CFC incoming message methods
- IM gateway methods and commands
- CFML CFEvent structure
- warn
- info
- setOriginatorID
- data command
- submit Multi command
- submit command
- setGatewayType
- setGatewayID
- setData
- setCFCListeners
- outgoingMessage
- getStatusTimeStamp
- numberOfMessagesReceived
- numberOfMessagesSent
- removeBuddy
- removeDeny
- removePermit
- setNickName
- setPermitMode
- setStatus
- SMS Gateway CFEvent structure and commands
- SMS Gateway incoming message CFEvent structure
- getStatusAsString
- getProtocolName
- getPermitMode
- getPermitList
- getNickName
- getName
- getDenyList
- getCustomAwayMessage
- getQueueSize
- getMaxQueueSize
- getHelper
- getGatewayType
- getGatewayServices
- getGatewayID_1
- getGatewayID
- getData
- getCFCTimeout
- setCFCTimeout
- getCFCPath
- getCFCMethod
- GatewayServices class
- Gateway interface
- GatewayHelper interface
- addPermit
- addDeny
- addBuddy
- error
- debug
- Logger class
- stop
- start
- CFML event gateway SendGatewayMessage data parameter
- restart
- fatal
- SMS gateway message sending commands
- ColdFusion C++ CFX Reference
- ColdFusion Java CFX reference
- WDDX JavaScript Objects
- Cloud services
- ColdFusion and GCP Storage
- ColdFusion and GCP Firestore
- ColdFusion and GCP PubSub
- ColdFusion and Amazon S3
- ColdFusion and DynamoDB
- ColdFusion and Amazon SQS
- ColdFusion and Amazon SNS
- ColdFusion and MongoDB
- ColdFusion and Azure Blob
- ColdFusion and Azure Service Bus
- Multi-cloud storage services
- Multi-cloud RDS databases
- ColdFusion and Azure Cosmos DB
Description
Controls aspects of page processing, such as the output of HTML code in pages. The cfsetting tag can also be used in script style.
Category
Syntax
<cfsetting enableCFoutputOnly = "yes|no" requestTimeOut = "value in seconds" showDebugOutput = "yes|no" >
Script style syntax for cfsetting:
setting enablecfoutputonly="true" requesttimeout="0" showdebugoutput="yes";
You can specify this tag's attributes in an attributeCollection attribute whose value is a structure. Specify the structure name in the attributeCollection attribute and use the tag's attribute names as structure keys.
See also
cfcache, cfflush, cfheader, cfhtmlhead, cfinclude, cfprocessingdirective, cfsilent; Controlling debugging output with the cfsetting tag in the Developing ColdFusion Applications
History
ColdFusion MX 6.1: Changed behavior: if the tag has a body, ColdFusion executes its contents.
ColdFusion MX:
- Added the requestTimeOut attribute.
- The catchExceptionsByPattern attribute is obsolete. It does not work, and causes an error, in releases later than ColdFusion 5.
- Changed exception handling: the structured exception manager searches for the best-fit cfcatch handler. (In earlier releases, an exception was handled by the first cfcatch block that could handle an exception of its type.)
Attributes
Attribute |
Req/Opt |
Default |
Description |
|---|---|---|---|
enableCFoutputOnly |
Optional |
|
|
requestTimeout |
Optional |
|
|
showDebugOutput |
Optional |
yes |
|
Usage
The cfsetting requestTimeout attribute replaces the use of requestTimeOut within a URL. To enforce a page time-out, detect the URL variable and use code such as the following to change the page time-out:
<cfsetting RequestTimeout = "#URL.RequestTimeout#">
You can use this tag to manage whitespace in ColdFusion output pages. If you nest cfsetting tags: to make HTML output visible, match each enableCFoutputOnly = "Yes" statement with an enableCFoutputOnly = "No" statement. For example, after five enableCFoutputOnly = "Yes" statements, to enable HTML output, you must have five corresponding enableCFoutputOnly = "No" statements. If HTML output is enabled (no matter how many enableCFoutputOnly = "No" statements have been processed) the first enableCFoutputOnly = "Yes" statement blocks output.
If the debugging service is enabled and showDebugOutput =" Yes", the IsDebugMode function returns Yes; otherwise, No.
Releases after ColdFusion MX allow a </cfsetting> end tag; however, this end tag does not affect processing. The cfsetting attributes affect code inside and outside the cfsetting tag body. ColdFusion MX ignored code between cfsetting start and end tags.
Example
<p>CFSETTING is used to control the output of HTML code in ColdFusion pages. This tag can be used to minimize the amount of generated whitespace. <cfsetting enableCFoutputOnly = "Yes"> This text is not shown <cfsetting enableCFoutputOnly = "No"> <p>This text is shown <cfsetting enableCFoutputOnly = "Yes"> <cfoutput> <p>Text within cfoutput is always shown </cfoutput> <cfsetting enableCFoutputOnly = "No"> <cfoutput> <p>Text within cfoutput is always shown </cfoutput>
Real-world uses of the cfsetting tag
Business intelligence report generator
Your application generates complex business reports that query large datasets, perform calculations, and generate charts. These reports can take several minutes to complete, but the default ColdFusion timeout (typically 60 seconds) causes the request to fail before the report finishes.
Problem statement
- Reports require 5-10 minutes to generate due to large data volumes
- Default request timeout causes reports to fail midway
- Users see timeout errors instead of completed reports
- Cannot rely on server-wide timeout changes (affects all requests)
Solution
The cfsetting tag overrides default timeout for specific pages, sets different timeouts for different operations, or changes timeout without admin access.
<h1>Long-Running Report Generation Demo</h1>
<p><strong>What This Demo Shows:</strong> How to use cfsetting requestTimeout to handle long-running operations.</p>
<hr>
<!--- Set URL parameters with defaults --->
<cfparam name="url.reportType" default="">
<cfparam name="url.simulate" default="false">
<h2>Business Intelligence Reports</h2>
<p>Generate complex reports that require extended processing time. Each report type has a different timeout requirement based on its complexity.</p>
<!--- Report Selection Form --->
<form method="get">
<table cellpadding="8">
<tr>
<td><label><strong>Select Report Type:</strong></label></td>
<td>
<select name="reportType">
<option value="">-- Choose a Report --</option>
<cfset reports = [
{value: "quick", name: "Quick Summary (10 seconds)", timeout: 30},
{value: "standard", name: "Standard Report (30 seconds)", timeout: 60},
{value: "detailed", name: "Detailed Analysis (60 seconds)", timeout: 120},
{value: "comprehensive", name: "Comprehensive Report (90 seconds)", timeout: 180}
]>
<cfloop array="#reports#" index="report">
<cfoutput>
<option value="#report.value#" #url.reportType EQ report.value ? "selected" : ""#>
#report.name#
</option>
</cfoutput>
</cfloop>
</select>
</td>
</tr>
<tr>
<td colspan="2">
<input type="checkbox" name="simulate" value="true" <cfif url.simulate EQ "true">checked</cfif>>
Simulate processing time (for demo purposes)
</td>
</tr>
<tr>
<td colspan="2">
<button type="submit">Generate Report</button>
</td>
</tr>
</table>
</form>
<hr>
<!--- Process Report Generation --->
<cfif len(url.reportType) GT 0>
<!--- Determine timeout based on report type --->
<cfscript>
reportConfig = {
quick: {name: "Quick Summary Report", timeout: 30, processTime: 10},
standard: {name: "Standard Monthly Report", timeout: 60, processTime: 30},
detailed: {name: "Detailed Analytics Report", timeout: 120, processTime: 60},
comprehensive: {name: "Comprehensive Annual Report", timeout: 180, processTime: 90}
};
if (structKeyExists(reportConfig, url.reportType)) {
currentReport = reportConfig[url.reportType];
} else {
currentReport = {name: "Unknown Report", timeout: 30, processTime: 5};
}
</cfscript>
<!--- Set extended timeout for this report --->
<cfsetting requestTimeout="#currentReport.timeout#">
<div style="background-color: ##fff3cd; border-left: 4px solid ##ff9800; padding: 15px; margin: 15px 0;">
<cfoutput>
<h3>⏱️ Report Processing Started</h3>
<p><strong>Report:</strong> #currentReport.name#</p>
<p><strong>Timeout Set:</strong> #currentReport.timeout# seconds</p>
<p><strong>Estimated Time:</strong> #currentReport.processTime# seconds</p>
</cfoutput>
</div>
<cftry>
<!--- Record start time --->
<cfset startTime = getTickCount()>
<!--- Simulate long-running report generation --->
<cfif url.simulate EQ "true">
<p>Processing data (simulating #currentReport.processTime# seconds of work)...</p>
<cfflush>
<!--- Simulate processing in chunks to show progress --->
<cfset chunks = 5>
<cfset chunkTime = currentReport.processTime / chunks>
<cfloop from="1" to="#chunks#" index="i">
<cfset sleep(chunkTime * 1000)>
<cfoutput>
<p>✓ Progress: #i * 20#% complete (#i# of #chunks# stages done)</p>
</cfoutput>
<cfflush>
</cfloop>
</cfif>
<!--- Generate mock report data --->
<cfscript>
reportData = {
title: currentReport.name,
generatedDate: now(),
recordsProcessed: randRange(10000, 100000),
calculationsPerformed: randRange(50000, 500000),
chartsGenerated: randRange(5, 20),
totalRevenue: randRange(100000, 1000000),
totalOrders: randRange(1000, 10000)
};
</cfscript>
<!--- Calculate execution time --->
<cfset endTime = getTickCount()>
<cfset executionTime = (endTime - startTime) / 1000>
<!--- Display Report Results --->
<div style="background-color: ##d4edda; border: 1px solid ##c3e6cb; padding: 20px; margin: 15px 0;">
<h3 style="color: ##155724; margin-top: 0;">✓ Report Generated Successfully!</h3>
<cfoutput>
<h4>#reportData.title#</h4>
<p><strong>Generated:</strong> #dateTimeFormat(reportData.generatedDate, "yyyy-mm-dd HH:nn:ss")#</p>
<p><strong>Execution Time:</strong> #numberFormat(executionTime, "0.00")# seconds (within #currentReport.timeout# second timeout)</p>
</cfoutput>
<hr>
<h4>Report Summary:</h4>
<table border="1" cellpadding="8" cellspacing="0" style="border-collapse: collapse;">
<cfoutput>
<tr>
<td><strong>Records Processed:</strong></td>
<td>#numberFormat(reportData.recordsProcessed, "0,000")#</td>
</tr>
<tr>
<td><strong>Calculations Performed:</strong></td>
<td>#numberFormat(reportData.calculationsPerformed, "0,000")#</td>
</tr>
<tr>
<td><strong>Charts Generated:</strong></td>
<td>#reportData.chartsGenerated#</td>
</tr>
<tr style="background-color: ##e3f2fd;">
<td><strong>Total Revenue:</strong></td>
<td>$#numberFormat(reportData.totalRevenue, "0,000.00")#</td>
</tr>
<tr style="background-color: ##e3f2fd;">
<td><strong>Total Orders:</strong></td>
<td>#numberFormat(reportData.totalOrders, "0,000")#</td>
</tr>
</cfoutput>
</table>
<p style="margin-top: 20px;"><em>Report completed within timeout limit. No timeout error occurred.</em></p>
</div>
<cfcatch type="any">
<div style="background-color: ##f8d7da; border: 1px solid ##f5c6cb; padding: 15px; margin: 15px 0;">
<h3 style="color: ##721c24; margin-top: 0;">✗ Report Generation Failed</h3>
<cfoutput>
<p><strong>Error:</strong> #cfcatch.message#</p>
<p><strong>Type:</strong> #cfcatch.type#</p>
</cfoutput>
<p>The report may have exceeded the timeout limit or encountered an error.</p>
</div>
</cfcatch>
</cftry>
</cfif>
<hr>
<h2>Example 2: Disable Timeout for Critical Operations</h2>
<cfparam name="form.operationType" default="">
<cfparam name="form.duration" default="3">
<!--- Check if form was submitted --->
<cfset showResults = structKeyExists(form, "runOperation") AND len(form.operationType) GT 0>
<!--- Process if form submitted --->
<cfif showResults>
<!--- Disable timeout completely for critical operations --->
<cfsetting requestTimeout="0">
<div style="background-color: ##ffebee; border: 2px solid ##f44336; padding: 20px; margin: 20px 0;">
<h3 style="color: ##c62828; margin-top: 0;">🔒 CRITICAL OPERATION MODE - TIMEOUT DISABLED</h3>
<table cellpadding="5" style="width: 100%;">
<tr>
<td style="font-size: 16px;"><strong>Request Timeout:</strong></td>
<td style="font-size: 16px; color: ##f44336; font-weight: bold;">DISABLED (Infinite)</td>
</tr>
<tr>
<td style="font-size: 16px;"><strong>Operation Type:</strong></td>
<td style="font-size: 16px;"><cfoutput>#form.operationType#</cfoutput></td>
</tr>
<tr>
<td style="font-size: 16px;"><strong>Expected Duration:</strong></td>
<td style="font-size: 16px;"><cfoutput>#form.duration# seconds</cfoutput></td>
</tr>
</table>
</div>
<!--- Simulate processing --->
<cfset startTime = getTickCount()>
<cfset sleepTime = val(form.duration) * 1000>
<cfset sleep(sleepTime)>
<cfset endTime = getTickCount()>
<cfset executionSeconds = (endTime - startTime) / 1000>
<!--- Generate operation steps based on type --->
<cfscript>
operationSteps = [];
switch(form.operationType) {
case "Database Backup":
operationSteps = [
"Database tables locked for consistency",
"Data files copied to backup location",
"Transaction logs archived",
"Backup integrity verified",
"Database tables unlocked"
];
break;
case "Data Migration":
operationSteps = [
"Source database connected",
"Data extraction completed",
"Data transformation applied",
"Target database loaded",
"Migration verified successfully"
];
break;
case "Index Rebuild":
operationSteps = [
"Fragmented indexes identified",
"Index rebuild initiated",
"Statistics updated",
"Query performance optimized",
"Index maintenance completed"
];
break;
case "Batch Report Generation":
operationSteps = [
"Data collected from sources",
"Calculations performed",
"Charts and graphs generated",
"PDF documents created",
"Reports distributed to users"
];
break;
}
recordsProcessed = randRange(10000, 50000);
dataProcessedMB = randRange(100, 1000);
</cfscript>
<!--- Show detailed results --->
<div style="background-color: ##fff3cd; border: 2px solid ##ffc107; padding: 20px; margin: 20px 0;">
<h4 style="margin-top: 0; font-size: 18px;">✓ Operation Steps Completed</h4>
<table border="1" cellpadding="12" cellspacing="0" style="border-collapse: collapse; width: 100%; background-color: white;">
<tr style="background-color: ##f0f0f0;">
<th style="width: 10%;">Step</th>
<th style="width: 70%;">Action</th>
<th style="width: 20%;">Status</th>
</tr>
<cfset stepNum = 0>
<cfloop array="#operationSteps#" index="step">
<cfset stepNum = stepNum + 1>
<cfoutput>
<tr>
<td style="text-align: center; font-weight: bold;">#stepNum#</td>
<td>#step#</td>
<td style="color: green; font-weight: bold; text-align: center;">✓ Complete</td>
</tr>
</cfoutput>
</cfloop>
</table>
</div>
<div style="background-color: ##d4edda; border: 2px solid ##28a745; padding: 20px; margin: 20px 0;">
<h3 style="color: ##155724; margin-top: 0; font-size: 20px;">✓ SUCCESS - Critical Operation Completed!</h3>
<cfoutput>
<table cellpadding="8" style="width: 100%; font-size: 16px;">
<tr>
<td style="width: 40%;"><strong>Operation Type:</strong></td>
<td style="width: 60%;">#form.operationType#</td>
</tr>
<tr>
<td><strong>Execution Time:</strong></td>
<td>#numberFormat(executionSeconds, "0.00")# seconds</td>
</tr>
<tr>
<td><strong>Timeout Setting:</strong></td>
<td><span style="color: ##f44336; font-weight: bold;">DISABLED (No Limit)</span></td>
</tr>
<tr>
<td><strong>Steps Completed:</strong></td>
<td>#arrayLen(operationSteps)# of #arrayLen(operationSteps)#</td>
</tr>
<tr>
<td><strong>Records Processed:</strong></td>
<td>#numberFormat(recordsProcessed, "0,000")#</td>
</tr>
<tr>
<td><strong>Data Processed:</strong></td>
<td>#numberFormat(dataProcessedMB, "0,000")# MB</td>
</tr>
</table>
<hr style="margin: 20px 0;">
<p style="background-color: ##fff; padding: 15px; border-left: 4px solid ##28a745;"><strong>🎯 Key Point:</strong> With <code>requestTimeout="0"</code>, this operation could have run for hours or even days without timing out. This is essential for critical maintenance tasks that cannot be interrupted.</p>
</cfoutput>
</div>
<p><a href="?" style="padding: 10px 20px; background-color: ##0066cc; color: white; text-decoration: none; display: inline-block; font-size: 16px;">← Run Another Operation</a></p>
<cfelse>
<!--- Show interactive form --->
<div style="background-color: ##e3f2fd; border: 2px solid ##0066cc; padding: 20px; margin: 20px 0;">
<h4 style="margin-top: 0;">Interactive Demo: Critical Operations with No Timeout</h4>
<p>This demo shows how <code>requestTimeout="0"</code> disables timeouts for mission-critical operations. Select an operation type and duration below.</p>
</div>
<form method="post" style="background-color: ##f9f9f9; border: 2px solid ##ddd; padding: 25px; margin: 20px 0;">
<h4 style="margin-top: 0;">Configure Critical Operation</h4>
<table cellpadding="10">
<tr>
<td style="vertical-align: top; padding-top: 5px;"><label><strong>Operation Type:</strong></label></td>
<td>
<select name="operationType" style="width: 300px; padding: 8px; font-size: 14px;" required>
<option value="">-- Select Operation --</option>
<option value="Database Backup">Database Backup</option>
<option value="Data Migration">Data Migration</option>
<option value="Index Rebuild">Index Rebuild</option>
<option value="Batch Report Generation">Batch Report Generation</option>
</select>
</td>
</tr>
<tr>
<td style="vertical-align: top; padding-top: 5px;"><label><strong>Simulation Duration:</strong></label></td>
<td>
<select name="duration" style="width: 300px; padding: 8px; font-size: 14px;">
<option value="2">2 seconds (Quick test)</option>
<option value="3" selected>3 seconds (Normal)</option>
<option value="5">5 seconds (Extended)</option>
<option value="8">8 seconds (Long running)</option>
<option value="10">10 seconds (Very long)</option>
</select>
<br>
<small style="color: ##666;">In real scenarios, these operations could take hours</small>
</td>
</tr>
<tr>
<td colspan="2" style="padding-top: 20px;">
<button type="submit" name="runOperation" style="padding: 12px 30px; background-color: ##f44336; color: white; border: none; font-size: 16px; font-weight: bold; cursor: pointer; border-radius: 5px;">
🚀 Execute Critical Operation (No Timeout)
</button>
</td>
</tr>
</table>
</form>
<div style="background-color: ##fff3e0; border-left: 4px solid ##ff9800; padding: 15px; margin: 20px 0;">
<h4 style="margin-top: 0;">⚠️ Real-World Use Cases</h4>
<ul style="line-height: 1.8;">
<li><strong>Database Backup:</strong> Full database backups can take hours for large databases</li>
<li><strong>Data Migration:</strong> Moving millions of records between systems</li>
<li><strong>Index Rebuild:</strong> Rebuilding database indexes on production systems</li>
<li><strong>Batch Reports:</strong> Generating thousands of complex reports overnight</li>
</ul>
<p><strong>Note:</strong> Always use <code>requestTimeout="0"</code> only for trusted administrative operations, never for public-facing pages.</p>
</div>
</cfif>
<hr>
Performance optimization of high-traffic web applications
Your e-commerce site serves millions of page views daily. Reducing page size improves load times, bandwidth costs, and SEO rankings. Unnecessary whitespace in HTML output adds to page weight and slows down page delivery.
Problem statement
- HTML output contains excessive whitespace between tags
- ColdFusion code comments and formatting create whitespace in output
- Larger page sizes increase bandwidth costs
- Slower page load times affect user experience and SEO
Solution
The cfsetting tag suppresses HTML outside cfoutput tags, outputs only what's needed, or generates compact HTML for production.
<h1>Whitespace Control for Performance Demo</h1>
<p><strong>What This Demo Shows:</strong> How to use cfsetting enableCFoutputOnly to minimize HTML output and improve performance.</p>
<hr>
<cfparam name="url.mode" default="normal">
<h2>HTML Output Comparison</h2>
<p>Compare HTML output with and without whitespace control. View page source to see the difference.</p>
<form method="get">
<label><strong>Output Mode:</strong></label>
<select name="mode" onchange="this.form.submit()">
<cfoutput>
<option value="normal" #url.mode EQ "normal" ? "selected" : ""#>Normal (with whitespace)</option>
<option value="controlled" #url.mode EQ "controlled" ? "selected" : ""#>Controlled (minimized whitespace)</option>
</cfoutput>
</select>
</form>
<hr>
<!--- Example 1: Normal Mode (with whitespace) --->
<cfif url.mode EQ "normal">
<div style="background-color: ##fff3cd; border-left: 4px solid ##ff9800; padding: 15px; margin: 15px 0;">
<h3>Normal Mode (Whitespace Included)</h3>
<p>HTML and whitespace from all code is included in output. View page source to see extra whitespace.</p>
</div>
<!--- This whitespace will appear in output --->
<cfscript>
// Generate product data
products = [
{id: 1, name: "Laptop Pro", price: 1299.99, stock: 15},
{id: 2, name: "Wireless Mouse", price: 29.99, stock: 50},
{id: 3, name: "USB-C Cable", price: 12.99, stock: 100}
];
</cfscript>
<!--- More whitespace here --->
<h3>Product Listing (Normal Output):</h3>
<table border="1" cellpadding="8" cellspacing="0" style="border-collapse: collapse;">
<tr style="background-color: ##f0f0f0;">
<th>ID</th>
<th>Product</th>
<th>Price</th>
<th>Stock</th>
</tr>
<cfloop array="#products#" index="product">
<cfoutput>
<tr>
<td>#product.id#</td>
<td>#product.name#</td>
<td>$#numberFormat(product.price, "0.00")#</td>
<td>#product.stock#</td>
</tr>
</cfoutput>
</cfloop>
</table>
<p><strong>Notice:</strong> View page source - you'll see whitespace from CFML code blocks appearing in the HTML.</p>
<!--- Example 2: Controlled Mode (whitespace minimized) --->
<cfelse>
<div style="background-color: ##d4edda; border-left: 4px solid ##28a745; padding: 15px; margin: 15px 0;">
<h3>Controlled Mode (Whitespace Minimized)</h3>
<p>Only HTML inside cfoutput tags is included. View page source to see compact HTML.</p>
</div>
<!--- Enable CFOutput Only mode to suppress whitespace --->
<cfsetting enableCFoutputOnly="yes">
This text will NOT appear in output because it's outside cfoutput tags.
<cfscript>
// Generate product data
products = [
{id: 1, name: "Laptop Pro", price: 1299.99, stock: 15},
{id: 2, name: "Wireless Mouse", price: 29.99, stock: 50},
{id: 3, name: "USB-C Cable", price: 12.99, stock: 100}
];
// This whitespace from the script block won't appear in output
</cfscript>
All this HTML markup will be suppressed - it won't appear in the final output!
<cfoutput>
<h3>Product Listing (Controlled Output):</h3>
<table border="1" cellpadding="8" cellspacing="0" style="border-collapse: collapse;">
<tr style="background-color: ##f0f0f0;">
<th>ID</th>
<th>Product</th>
<th>Price</th>
<th>Stock</th>
</tr>
</cfoutput>
<cfloop array="#products#" index="product">
<cfoutput>
<tr>
<td>#product.id#</td>
<td>#product.name#</td>
<td>$#numberFormat(product.price, "0.00")#</td>
<td>#product.stock#</td>
</tr>
</cfoutput>
</cfloop>
<cfoutput>
</table>
<p><strong>Notice:</strong> View page source - HTML is more compact with minimal whitespace.</p>
</cfoutput>
<!--- Disable CFOutput Only mode to allow normal HTML again --->
<cfsetting enableCFoutputOnly="no">
</cfif>
<hr>
<h2>Example 3: Clean HTML Email Generation</h2>
<cfparam name="url.generateEmail" default="false">
<cfif url.generateEmail EQ "true">
<!--- First generate email WITHOUT whitespace control to compare --->
<cfsetting enableCFoutputOnly="no">
<cfscript>
// Email data
emailData = {
customerName: "John Smith",
orderNumber: "ORD-" & randRange(10000, 99999),
orderDate: now(),
shippingAddress: "123 Main Street, Springfield, IL 62701",
items: [
{name: "Wireless Headphones", quantity: 2, price: 49.99, total: 99.98},
{name: "USB-C Cable 6ft", quantity: 3, price: 12.99, total: 38.97},
{name: "Phone Case", quantity: 1, price: 24.99, total: 24.99}
],
subtotal: 163.94,
shipping: 8.99,
tax: 13.91,
total: 186.84
};
// Generate email WITHOUT whitespace control (normal way)
emailHTMLNormal = "";
</cfscript>
<cfsavecontent variable="emailHTMLNormal">
<cfoutput>
<html>
<body style="font-family: Arial, sans-serif; max-width: 600px; margin: 0 auto;">
<div style="background-color: ##0066cc; color: white; padding: 20px; text-align: center;">
<h2 style="margin: 0;">Order Confirmation</h2>
</div>
<div style="padding: 20px;">
<p>Dear #emailData.customerName#,</p>
<p>Thank you for your order! Your items will be shipped to:</p>
<p style="background-color: ##f0f0f0; padding: 10px; border-left: 4px solid ##0066cc;">
#emailData.shippingAddress#
</p>
<p><strong>Order Number:</strong> #emailData.orderNumber#<br>
<strong>Order Date:</strong> #dateFormat(emailData.orderDate, "mmmm d, yyyy")#</p>
<h3>Order Details</h3>
<table border="1" cellpadding="10" cellspacing="0" style="border-collapse: collapse; width: 100%;">
<tr style="background-color: ##f0f0f0;">
<th align="left">Product</th><th>Qty</th><th align="right">Price</th><th align="right">Total</th>
</tr>
</cfoutput>
<cfloop array="#emailData.items#" index="item">
<cfoutput>
<tr>
<td>#item.name#</td>
<td align="center">#item.quantity#</td>
<td align="right">$#numberFormat(item.price, "0.00")#</td>
<td align="right">$#numberFormat(item.total, "0.00")#</td>
</tr>
</cfoutput>
</cfloop>
<cfoutput>
<tr>
<td colspan="3" align="right"><strong>Subtotal:</strong></td>
<td align="right">$#numberFormat(emailData.subtotal, "0.00")#</td>
</tr>
<tr>
<td colspan="3" align="right"><strong>Shipping:</strong></td>
<td align="right">$#numberFormat(emailData.shipping, "0.00")#</td>
</tr>
<tr>
<td colspan="3" align="right"><strong>Tax:</strong></td>
<td align="right">$#numberFormat(emailData.tax, "0.00")#</td>
</tr>
<tr style="background-color: ##e3f2fd; font-weight: bold; font-size: 16px;">
<td colspan="3" align="right">TOTAL:</td>
<td align="right">$#numberFormat(emailData.total, "0.00")#</td>
</tr>
</table>
<p style="margin-top: 30px;">Thank you for your business!</p>
<p style="color: ##666; font-size: 12px;">Questions? Contact us at support@example.com</p>
</div>
</body>
</html>
</cfoutput>
</cfsavecontent>
<!--- Now generate WITH whitespace control (clean version) --->
<cfsetting enableCFoutputOnly="yes">
<cfset emailHTMLClean = "">
<cfsavecontent variable="emailHTMLClean">
<cfoutput>
<html>
<body style="font-family: Arial, sans-serif; max-width: 600px; margin: 0 auto;">
<div style="background-color: ##0066cc; color: white; padding: 20px; text-align: center;">
<h2 style="margin: 0;">Order Confirmation</h2>
</div>
<div style="padding: 20px;">
<p>Dear #emailData.customerName#,</p>
<p>Thank you for your order! Your items will be shipped to:</p>
<p style="background-color: ##f0f0f0; padding: 10px; border-left: 4px solid ##0066cc;">
#emailData.shippingAddress#
</p>
<p><strong>Order Number:</strong> #emailData.orderNumber#<br>
<strong>Order Date:</strong> #dateFormat(emailData.orderDate, "mmmm d, yyyy")#</p>
<h3>Order Details</h3>
<table border="1" cellpadding="10" cellspacing="0" style="border-collapse: collapse; width: 100%;">
<tr style="background-color: ##f0f0f0;">
<th align="left">Product</th><th>Qty</th><th align="right">Price</th><th align="right">Total</th>
</tr>
</cfoutput>
<cfloop array="#emailData.items#" index="item">
<cfoutput>
<tr>
<td>#item.name#</td>
<td align="center">#item.quantity#</td>
<td align="right">$#numberFormat(item.price, "0.00")#</td>
<td align="right">$#numberFormat(item.total, "0.00")#</td>
</tr>
</cfoutput>
</cfloop>
<cfoutput>
<tr>
<td colspan="3" align="right"><strong>Subtotal:</strong></td>
<td align="right">$#numberFormat(emailData.subtotal, "0.00")#</td>
</tr>
<tr>
<td colspan="3" align="right"><strong>Shipping:</strong></td>
<td align="right">$#numberFormat(emailData.shipping, "0.00")#</td>
</tr>
<tr>
<td colspan="3" align="right"><strong>Tax:</strong></td>
<td align="right">$#numberFormat(emailData.tax, "0.00")#</td>
</tr>
<tr style="background-color: ##e3f2fd; font-weight: bold; font-size: 16px;">
<td colspan="3" align="right">TOTAL:</td>
<td align="right">$#numberFormat(emailData.total, "0.00")#</td>
</tr>
</table>
<p style="margin-top: 30px;">Thank you for your business!</p>
<p style="color: ##666; font-size: 12px;">Questions? Contact us at support@example.com</p>
</div>
</body>
</html>
</cfoutput>
</cfsavecontent>
<!--- Restore normal output --->
<cfsetting enableCFoutputOnly="no">
<!--- Calculate savings --->
<cfset normalSize = len(emailHTMLNormal)>
<cfset cleanSize = len(emailHTMLClean)>
<cfset savedBytes = normalSize - cleanSize>
<cfset savedPercent = (savedBytes / normalSize) * 100>
<!--- Show comparison --->
<div style="background-color: ##d4edda; border: 2px solid ##28a745; padding: 20px; margin: 20px 0;">
<h3 style="color: ##155724; margin-top: 0;">✓ Email Generated Successfully!</h3>
<cfoutput>
<table cellpadding="8" style="width: 100%; font-size: 16px;">
<tr style="background-color: ##fff;">
<td style="width: 50%;"><strong>Order Number:</strong></td>
<td style="width: 50%;">#emailData.orderNumber#</td>
</tr>
<tr style="background-color: ##fff;">
<td><strong>Customer:</strong></td>
<td>#emailData.customerName#</td>
</tr>
<tr style="background-color: ##fff;">
<td><strong>Order Total:</strong></td>
<td>$#numberFormat(emailData.total, "0.00")#</td>
</tr>
<tr style="background-color: ##fff;">
<td><strong>Items:</strong></td>
<td>#arrayLen(emailData.items)# products</td>
</tr>
</table>
</cfoutput>
</div>
<!--- File Size Comparison --->
<div style="background-color: ##fff3cd; border: 2px solid ##ffc107; padding: 20px; margin: 20px 0;">
<h3 style="margin-top: 0;">📊 Whitespace Control Impact</h3>
<cfoutput>
<table border="1" cellpadding="12" cellspacing="0" style="border-collapse: collapse; width: 100%; background-color: white;">
<tr style="background-color: ##f0f0f0;">
<th style="width: 40%;">Method</th>
<th style="width: 30%;">File Size</th>
<th style="width: 30%;">Savings</th>
</tr>
<tr>
<td><strong>Normal (No Whitespace Control)</strong></td>
<td style="text-align: right;">#numberFormat(normalSize, "0,000")# bytes</td>
<td style="text-align: center;">-</td>
</tr>
<tr style="background-color: ##e8f5e9;">
<td><strong>Clean (enableCFoutputOnly="yes")</strong></td>
<td style="text-align: right; color: green; font-weight: bold;">#numberFormat(cleanSize, "0,000")# bytes</td>
<td style="text-align: center; color: green; font-weight: bold;">↓ #numberFormat(savedBytes, "0,000")# bytes</td>
</tr>
<tr style="background-color: ##e3f2fd;">
<td colspan="2"><strong>Reduction Percentage:</strong></td>
<td style="text-align: center; font-size: 18px; font-weight: bold; color: ##0066cc;">#numberFormat(savedPercent, "0.0")#%</td>
</tr>
</table>
<p style="margin-top: 15px; background-color: white; padding: 15px; border-left: 4px solid ##28a745;">
<strong>💡 Result:</strong> By using <code>enableCFoutputOnly="yes"</code>, the email HTML is <strong>#numberFormat(savedPercent, "0.0")#% smaller</strong>, reducing bandwidth and improving email delivery speed!
</p>
</cfoutput>
</div>
<!--- Side-by-side code comparison --->
<h3>HTML Code Comparison:</h3>
<table style="width: 100%; border-collapse: collapse;">
<tr>
<td style="width: 50%; vertical-align: top; padding-right: 10px;">
<h4>Normal HTML (With Whitespace):</h4>
<textarea rows="15" style="width: 100%; font-family: monospace; font-size: 10px;"><cfoutput>#emailHTMLNormal#</cfoutput></textarea>
<cfoutput>
<p style="font-size: 12px; color: ##666;">Size: #numberFormat(normalSize, "0,000")# bytes</p>
</cfoutput>
</td>
<td style="width: 50%; vertical-align: top; padding-left: 10px;">
<h4 style="color: green;">Clean HTML (Whitespace Controlled):</h4>
<textarea rows="15" style="width: 100%; font-family: monospace; font-size: 10px; border: 2px solid green;"><cfoutput>#emailHTMLClean#</cfoutput></textarea>
<cfoutput>
<p style="font-size: 12px; color: green; font-weight: bold;">Size: #numberFormat(cleanSize, "0,000")# bytes (↓ #numberFormat(savedPercent, "0.0")#%)</p>
</cfoutput>
</td>
</tr>
</table>
<!--- Email Preview --->
<h3 style="margin-top: 30px;">📧 Email Preview:</h3>
<div style="border: 3px solid ##0066cc; padding: 10px; background-color: ##f9f9f9; margin: 20px 0;">
<p style="text-align: center; color: ##666; font-size: 12px; margin: 5px 0;">Preview of how the email will look to customers:</p>
<div style="background-color: white;">
<cfoutput>#emailHTMLClean#</cfoutput>
</div>
</div>
<p style="text-align: center; margin: 30px 0;">
<a href="?" style="padding: 10px 20px; background-color: ##0066cc; color: white; text-decoration: none; display: inline-block;">← Generate Another Email</a>
</p>
<cfelse>
<div style="background-color: ##e3f2fd; border: 2px solid ##0066cc; padding: 20px; margin: 20px 0;">
<h4 style="margin-top: 0;">Email HTML Generation with Whitespace Control</h4>
<p>This example demonstrates how <code>enableCFoutputOnly="yes"</code> creates cleaner, more compact HTML for email generation.</p>
<p><strong>Benefits for Email:</strong></p>
<ul>
<li>Smaller email size = faster delivery</li>
<li>Reduced HTML means less spam filter triggers</li>
<li>Cleaner code is easier to debug</li>
<li>Better compatibility with email clients</li>
</ul>
</div>
<p style="text-align: center; margin: 30px 0;">
<a href="?mode=#url.mode#&generateEmail=true" style="padding: 15px 30px; background-color: ##28a745; color: white; text-decoration: none; display: inline-block; font-size: 18px; font-weight: bold; border-radius: 5px;">
📧 Generate Email & Compare Sizes
</a>
</p>
</cfif>
<hr>
Production website with environment-specific debug control
Your application needs different debug output behavior in development vs. production environments. In production, you must hide debug information to prevent security risks and provide clean output to users, while in development you need full debugging.
Problem statement
- Debug output should never appear in production
- Sensitive system information could leak to users
- Debug output adds unnecessary data to responses
- Need environment-specific debug control
Solution
The cfsetting tag hides ebug info in production environments, suppresses debug in API responses, or overrides server debug settings per page.
<h1>Production Debug Output Control Demo</h1>
<p><strong>What This Demo Shows:</strong> How to use cfsetting showDebugOutput to hide debug information in production.</p>
<hr>
<cfparam name="url.environment" default="production">
<cfparam name="url.pageType" default="html">
<!--- Set environment --->
<cfset application.environment = url.environment>
<!--- Apply debug output control based on environment --->
<cfif application.environment EQ "production">
<cfsetting showDebugOutput="no">
<cfelse>
<cfsetting showDebugOutput="yes">
</cfif>
<h2>Environment Configuration</h2>
<form method="get">
<table cellpadding="8">
<tr>
<td><label><strong>Environment:</strong></label></td>
<td>
<select name="environment" onchange="this.form.submit()">
<cfoutput>
<option value="development" #url.environment EQ "development" ? "selected" : ""#>Development (Debug ON)</option>
<option value="production" #url.environment EQ "production" ? "selected" : ""#>Production (Debug OFF)</option>
</cfoutput>
</select>
</td>
</tr>
<tr>
<td><label><strong>Page Type:</strong></label></td>
<td>
<select name="pageType" onchange="this.form.submit()">
<cfoutput>
<option value="html" #url.pageType EQ "html" ? "selected" : ""#>HTML Page</option>
<option value="api" #url.pageType EQ "api" ? "selected" : ""#>API Endpoint</option>
<option value="ajax" #url.pageType EQ "ajax" ? "selected" : ""#>AJAX Response</option>
</cfoutput>
</select>
</td>
</tr>
</table>
</form>
<hr>
<!--- Display current environment settings --->
<div style="background-color: <cfoutput>#application.environment EQ 'production' ? '##ffebee' : '##e8f5e9'#</cfoutput>; border-left: 4px solid <cfoutput>#application.environment EQ 'production' ? '##f44336' : '##4caf50'#</cfoutput>; padding: 15px; margin: 15px 0;">
<cfoutput>
<h3>Current Environment: #uCase(application.environment)#</h3>
<p><strong>Debug Output:</strong> #application.environment EQ "production" ? "DISABLED" : "ENABLED"#</p>
<p><strong>Page Type:</strong> #url.pageType#</p>
<p><strong>IsDebugMode():</strong> #isDebugMode()#</p>
</cfoutput>
</div>
<!--- Example output based on page type --->
<cfif url.pageType EQ "api">
<!--- API Endpoint - Always suppress debug output --->
<cfsetting showDebugOutput="no">
<h3>API Endpoint Example</h3>
<cfscript>
// Simulate API response
apiResponse = {
status: "success",
timestamp: now(),
data: {
users: [
{id: 1, name: "John Doe", email: "john@example.com"},
{id: 2, name: "Jane Smith", email: "jane@example.com"}
],
totalCount: 2
}
};
</cfscript>
<div style="background-color: ##f0f0f0; padding: 15px; border: 1px solid ##ddd;">
<h4>API Response (JSON):</h4>
<pre style="background-color: white; padding: 10px; overflow: auto;"><cfoutput>#serializeJSON(apiResponse, "struct")#</cfoutput></pre>
<p><strong>✓ Note:</strong> No debug output will appear after this API response, even in development mode.</p>
</div>
<cfelseif url.pageType EQ "ajax">
<!--- AJAX Response - Suppress debug output --->
<cfsetting showDebugOutput="no">
<h3>AJAX Response Example</h3>
<cfscript>
// Simulate AJAX response
ajaxData = {
success: true,
message: "Data loaded successfully",
items: [
{id: 101, title: "Product A", price: 49.99},
{id: 102, title: "Product B", price: 29.99},
{id: 103, title: "Product C", price: 39.99}
]
};
</cfscript>
<div style="background-color: ##f0f0f0; padding: 15px; border: 1px solid ##ddd;">
<h4>AJAX Response Data:</h4>
<table border="1" cellpadding="8" cellspacing="0" style="border-collapse: collapse; background-color: white;">
<tr style="background-color: ##0066cc; color: white;">
<th>ID</th>
<th>Title</th>
<th>Price</th>
</tr>
<cfloop array="#ajaxData.items#" index="item">
<cfoutput>
<tr>
<td>#item.id#</td>
<td>#item.title#</td>
<td>$#numberFormat(item.price, "0.00")#</td>
</tr>
</cfoutput>
</cfloop>
</table>
<p><strong>✓ Note:</strong> No debug output will appear after this AJAX response.</p>
</div>
<cfelse>
<!--- Regular HTML Page - Use environment setting --->
<h3>HTML Page Example</h3>
<cfscript>
// Simulate page data
pageData = {
title: "Dashboard",
user: {
id: 1,
name: "Admin User",
role: "Administrator"
},
stats: {
totalOrders: 1543,
revenue: 125430.50,
activeUsers: 234
}
};
</cfscript>
<div style="background-color: ##e3f2fd; padding: 20px; border: 1px solid ##0066cc;">
<cfoutput>
<h4>#pageData.title#</h4>
<p><strong>User:</strong> #pageData.user.name# (#pageData.user.role#)</p>
<hr>
<h4>Statistics:</h4>
<p><strong>Total Orders:</strong> #numberFormat(pageData.stats.totalOrders, "0,000")#</p>
<p><strong>Revenue:</strong> $#numberFormat(pageData.stats.revenue, "0,000.00")#</p>
<p><strong>Active Users:</strong> #numberFormat(pageData.stats.activeUsers, "0,000")#</p>
</cfoutput>
</div>
<cfif application.environment EQ "development">
<p><strong>✓ Note:</strong> In development mode, debug output will appear at the end of this page (if enabled in CF Administrator).</p>
<cfelse>
<p><strong>✓ Note:</strong> In production mode, debug output is suppressed for security and performance.</p>
</cfif>
</cfif>
<hr>
<h2>Example: Conditional Debug Control</h2>
<cfparam name="url.isAdmin" default="false">
<cfif url.isAdmin EQ "true">
<!--- Admin users can see debug output even in production --->
<cfsetting showDebugOutput="yes">
<div style="background-color: ##fff3cd; border-left: 4px solid ##ff9800; padding: 15px; margin: 15px 0;">
<h3>🔧 Administrator Debug Mode</h3>
<p><strong>Debug Output:</strong> ENABLED (Admin Override)</p>
<p>As an administrator, you can see debug information even in production mode.</p>
<p><a href="?environment=#url.environment#&pageType=#url.pageType#&isAdmin=false">Disable Admin Mode</a></p>
</div>
<cfelse>
<p><a href="?environment=#url.environment#&pageType=#url.pageType#&isAdmin=true" style="padding: 10px 20px; background-color: ##ff9800; color: white; text-decoration: none; display: inline-block;">Enable Admin Debug Mode</a></p>
</cfif>
<hr>