![MACROMEDIA COLDFUSION 5-DEVELOPING Develop Manual Download Page 352](http://html1.mh-extra.com/html/macromedia/coldfusion-5-developing/coldfusion-5-developing_develop-manual_3293641352.webp)
332
Chapter 18 Interacting with Remote Servers
Using cfhttp to Interact with the Web
The
cfhttp
tag, which enables you to retrieve information from a remote server, is
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
cfhttp
tag: Get or Post.
•
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
cfhttp
retrieves an object.
•
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
to Post to another ColdFusion page, that page does not
display. It processes the request and returns the results to the original
ColdFusion page, which then uses the information as appropriate.
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,
cfhttp.fileContent
. The
following examples illustrate a few common Get operations.
To retrieve a file and store it in a variable:
1
Open a new file in ColdFusion Studio.
2
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>
3
(Optional) Replace the
url
attribute value with the URL of a file you want to get.
4
Save the file as
getwebpage.cfm
in
myapps
under your Web root directory and
view it in your browser.
Summary of Contents for COLDFUSION 5-DEVELOPING
Page 1: ...Macromedia Incorporated Developing ColdFusion Applications MacroMedia ColdFusion 5 ...
Page 58: ...38 Chapter 3 Querying a Database ...
Page 134: ...114 Chapter 7 Updating Your Database ...
Page 210: ...190 Chapter 10 Reusing Code ...
Page 232: ...212 Chapter 11 Preventing and Handling Errors ...
Page 238: ...218 Chapter 12 Using the Application Framework ...
Page 262: ...242 Chapter 12 Using the Application Framework ...
Page 278: ...258 Chapter 13 Extending ColdFusion Pages with CFML Scripting ...
Page 320: ...300 Chapter 15 Indexing and Searching Data ...
Page 336: ...316 Chapter 16 Sending and Receiving E mail ...
Page 374: ...354 Chapter 18 Interacting with Remote Servers ...