User Guide
94 Chapter 2: ColdFusion Tags
Usage
To set the character encoding (character set) of generated output, including the page HTML, use
code such as the following:
<cfcontent type="text/html; charset=ISO-8859-1">
When ColdFusion processes an HTTP request, it determines the character encoding to use for
the data it returns in the HTTP response. By default, ColdFusion returns character data using the
Unicode UTF-8 format, regardless of the value of an HTML
meta tag in the page. You can use
the
cfcontent tag to override the default character encoding of the response. For example, to tell
ColdFusion MX to return the page using Japanese EUC character encoding, use the
type
attribute, as follows:
<cfcontent type="text/html; charset=EUC-JP">
If you call the cfcontent tag from a custom tag, and you do not want the tag to discard the
current page when it is called from another application or custom tag, set
reset = "no".
If a file delete operation is unsuccessful, ColdFusion throws an error.
Do not use this tag after the
cfflush tag on a page, it will have no effect or ColdFusion will
throw an error.
The following tag can force most browsers to display a dialog box that asks users whether they
want to save the contents of the file specified by the
cfcontent tag using the filename specified
by the
filename value. If the user selects to open the file, most browsers open the file in the
related application, not the browser window.
<cfheader name="Content-Disposition" value="attachment;
filename=filename.ext">
Some file types, such as PDF documents, do not use executable code and can display directly in
most browsers. To request the browser to display the file directly, use a
cfheader tag similar to
the following:
<cfheader name="Content-Disposition" value="inline; filename=name.ext">
You can use any value for the filename part of the filename attribute, but the ext part must be the
standard Windows extension for the file type.
variable Optional Name of a ColdFusion MX binary variable whose contents can
be displayed by the browser, such as the contents of a chart
generated by the
cfchart tag or a PDF or Excel file retrieved by
a
cffile action="readBinary" tag. When you use this
attribute, any other output on the current CFML page is
ignored; only the contents of the file are sent to the client.
reset Optional yes If you specify a
file or variable attribute, this attribute has no
effect; otherwise, it does the following:
• yes: discards output that precedes call to
cfcontent
• no: preserves output that precedes call to cfcontent. In this
case, all output is sent with the specified type.
Attribute Req/Opt Default Description