User Guide

Chapter 7: Using CGI with ColdFusion 271
Relative mappings. When application pages are stored in the Web server
document directory, you can use relative URLs to refer to graphics and other
files.
Increased performance. You will not realize the increased performance
provided by the Web server APIs.
Example applications. The example applications installed with ColdFusion will
not work without a server that supports one of the standard APIs.
Referencing Application Pages with CGI
ColdFusion includes a CGI script (cfml.exe) that is executed by your Web server
whenever a user submits a form or clicks a link that references it. The CGI script
communicates with the ColdFusion Application Server.
URLs and the cfml.exe script
You are probably familiar with using URLs to refer to documents and images on the
Web (e.g.,
http://www.myserver.com/homepage.htm). URLs also support an extended
syntax that allows you to call CGI programs and pass them parameters.
To invoke cfml.exe from a URL, specify the logical path to the executable on your
server along with a
template parameter indicating which application page file to use
in processing the request.
To pass parameters to the script, you append a "?" to it and then specify a list of
parameters in a ’key=value’ format (delimited by the & character).
For example, to call the script and tell it to use an application page file called
myquery.cfm, you would use the syntax:
/
cgi-shl
/cfml.exe?template=myquery.cfm
You can call the same application page with an additional parameter Employee_ID=346
using the syntax:
/
cgi-shl
/cfml.exe?template=myquery.cfm&Employee_ID=346
The cgi-shl entry italicized in the preceding examples represents the path to your
Web server’s CGI directory. Your servers CGI path may be different from this (other
common paths are cgi-bin and scripts). You should consult your Web servers
documentation to determine the appropriate path and (if necessary) use this path
instead of
cgi-shl.
One good way to verify that your server is able to access
cfml.exe is to create a simple
form without input fields that has an ACTION that calls the
cfml.exe script with no
arguments (for example,
ACTION="/cgi-shl/cfml.exe"). If the script is accessible,
your server returns an error message that indicates an application page was not
specified. If
cfml.exe is not accessible, your server returns an error message that
indicates it cannot find the script.