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.
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 server's CGI path may be different from this (other common paths are cgi-bin
and scripts
). You should consult your Web server's 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.
The reference to the file myquery.cfm
in the above example contains no path information. You may be wondering how ColdFusion determines where on your system to locate this file.
If you place ColdFusion application pages in the cfdocs
directory, you can reference them using only their base name. For example, if a file called myquery.cfm
is in the cfdocs
directory, you need only specify myquery.cfm
to refer to it.
If you create subdirectories within the cfdocs
directory, you can reference application pages within them using their subdirectory names. For example, if you put myquery.cfm
in a subdirectory called sales
, you would use /sales/myquery.cfm
to refer to it. The URL reference to this file would then be:
/cgi-shl/cfml.exe?template=/sales/myquery.cfm
To simplify URLs for your users, you can create mappings that point to directories. These mappings work like your Web server's document mappings, but they only refer to application pages. Define mappings on the Mappings page of the ColdFusion Administrator.