Adobe 38043740 - ColdFusion Standard - Mac Development Manual page 1239

Developing applications
Hide thumbs Also See for 38043740 - ColdFusion Standard - Mac:
Table of Contents

Advertisement

DEVELOPING COLDFUSION 9 APPLICATIONS
Using External Resources
Using cfhttp to interact with the web
The cfhttp tag, which lets you 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—Get or Post—to interact with a remote server using the
• Using the Get method, you can only send information to the remote server in the URL. This method is often used
for a one-way transaction in which
• Using the Post method, you can pass variables to a ColdFusion page or CGI program, which processes them and
returns data to the calling page. The calling page then appears or further processes the data that was received. For
example, when you use
cfhttp
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
Retrieve a file and store it in a variable
Create a ColdFusion page with the following content:
1
<html>
<head>
<title>Use Get Method</title>
</head>
<body>
<cfhttp
method="Get"
url="http://www.adobe.com"
resolveurl="Yes">
<cfoutput>
#cfhttp.FileContent# <br>
</cfoutput>
</body>
</html>
(Optional) Replace the value of the
2
3
Save the file as get_webpage.cfm in the myapps directory under your web_root and view it in the web browser.
The browser loads the web page specified in the
Reviewing the code
The following table describes the code and its function:
Code
<cfhttp method="Get"
url="http://www.adobe.com"
resolveurl="Yes">
<cfoutput>
#cfhttp.FileContent# <br>
</cfoutput>
Get a web page and save it in a file
Create a ColdFusion page with the following content:
1
retrieves an object.
cfhttp
to Post to another ColdFusion page, that page does not appear. It processes the
. The following examples show several common Get operations.
attribute with another URL.
url
attribute.
url
Description
Get the page specified in the URL and make the links absolute instead of relative
so that they appear properly.
Display the page, which is stored in the variable
browser.
Last updated 1/20/2012
tag:
cfhttp
, in the
cfhttp.fileContent
1234

Advertisement

Table of Contents
loading

This manual is also suitable for:

Coldfusion 9

Table of Contents