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
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 has no effect or ColdFusion throws 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.
For file types that might contain executable
code, such as Microsoft Excel documents, most browsers always ask
before opening the document. For these file types, the inline content
disposition specification requests the browser to display the file
directly if the user selects to open the file.
For more information
on character encodings, see the following web pages:
For a complete list of
media types used on the Internet, see www.iana.org/assignments/media-types/.