332
Using cfhttp to Interact with the Web
The
one of the more powerful tags in the CFML tag set. You can use one of two methods
to interact with a remote server using the
Using the cfhttp Get Method
You use Get to retrieve files, including text and binary files, from a specified server.
The retrieved information is stored in a special variable,
following examples illustrate a few common Get operations.
To retrieve a file and store it in a variable:
1
2
3
4
tag, which enables you to retrieve information from a remote server, is
cfhttp
Using the Get method, you can only send information to the remote server
directly in the URL. This method is often used for a one-way transaction in which
retrieves an object.
cfhttp
By comparison, the Post method can pass variables to a ColdFusion page or CGI
program, which processes them and returns data to the calling page. The calling
page then displays or further processes the data that was received. For example,
when you use
cfhttp
display. It processes the request and returns the results to the original
ColdFusion page, which then uses the information as appropriate.
Open a new file in ColdFusion Studio.
Modify the file so that it appears as follows:
<cfhttp method="Get"
url="http://www.ci.newton.ma.us/main.htm"
resolveurl="Yes">
<cfoutput>
#cfhttp.FileContent# <br>
</cfoutput>
(Optional) Replace the
Save the file as
getwebpage.cfm
view it in your browser.
Chapter 18 Interacting with Remote Servers
cfhttp
to Post to another ColdFusion page, that page does not
attribute value with the URL of a file you want to get.
url
in
myapps
tag: Get or Post.
cfhttp.fileContent
under your Web root directory and
. The
Need help?
Do you have a question about the COLDFUSION 5-DEVELOPING and is the answer not in the manual?
Questions and answers