Whatever message this page gives is out now! Go check it out!
<cfsetting
enableCFoutputOnly = "yes|no"
requestTimeOut = "value in seconds"
showDebugOutput = "yes|no" >setting enablecfoutputonly="true" requesttimeout="0" showdebugoutput="yes";Attribute | Req/Opt | Default | Description |
enableCFoutputOnly | Optional |
| |
requestTimeout | Optional |
| |
showDebugOutput | Optional | yes |
|
<cfsetting RequestTimeout = "#URL.RequestTimeout#"><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><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><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><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>