ASK THE CF DOCTOR
By Douglas Smith and Michael Smith
CF Doctor was at the CF 2001 Odyssey conference answering attendees’ ColdFusion
programming questions. We look at some popular questions and answers here.
A lot of users want to know how they can get to files
outside of the physical server that CF Server is located on. This includes ODBC connections to file
based databases, such as Access97.
This is a common problem that first time users of CF run into on
CF Server runs as “system”, which means is has permission to do
everything on the local box, but does not have any network permissions to go
out over the network and get files from other machines. If you need to do this, take the following
steps in NT:
Open the Services option from the control
Double click on the ColdFusion Executive
Change the “Log On As” option from “system” to
a real user, for example “Administrator” or make a new user just for this
ColdFusion service. Whatever
permissions this user has on the network, Coldfusion will then have.
Robert Irving, Biophoto
Verity Search has ceased functioning on the server and
any new collections can not be created.
This is a common problem when upgrading from CF Server 3.5 to 4.01. The real solution at this time is to upgrade
to 4.5, with the 4.5.1 patch.
However, you can also read about this problem in the Allaire's Knowledge base,
Article 9069. The solution suggested is to rename the following file:
Then delete the indexes and recreate.
Syed Hasan, MCI WorldCom
How can we enhance, and speed up dynamic web pages
generated by ColdFusion.
This is something everyone wants to know about, and entire
articles have been written on this subject!
But let’s try and be brief…
First, determine if the problem is with ColdFusion or with your
HTML. Turn on debugging in the CF
admin, and make sure you have “Show Processing Time” (with Detail View in 4.5)
turned on. Then check the time CF takes
to generate the page. If this is a large
number, then you need to spend some time optimizing your CF code. If the CF number is low, but the page still
takes a long time to display on the browser, then the problem is probably with
Common HTML Speed-Up Suggestions
up long tables! Page your data
display (Page 1 of 10 for example.), or close your tables every 100
records (or so) and start a new table.
you must display long tables, take out tabs and white spaces before all
<tr> and <td> tags.
You might loose your nicely indented code, but it really does help!
deeply nested tables (say, more than 5 or 6 tables deep).
you have the option, use IE. IE 4
handles nested tables (and long, complicated tables in general) much
better than Netscape 4.
sections that are CF code intensive between <CFSETTING
enablecfoutputonly=”YES”> and <CFSETTING enablecfoutputonly=”NO”>
tags to get rid of unwanted white space that takes time for your browser
Common CF Speed-Up Suggestions
CF template cache! Set your
template cache size in the CF admin to a larger number.
<CFQUERY cachedwithin or cachedafter option> to cache queries that
are likely to be similar, or do you own caching for global queries (like
lists of states or users, etc), run the query once on start up, and save
the query results to an application variable, and use that in <cfoutput
3. Make the database do more of the work! Most slow web
sites are due to inefficient use of the database behind the web site, so learn
more sophisticated SQL, and use stored procedures, grouping and calculated
fields in summary queries, instead of having CF do the calculations in a
loop. The database will ALWAYS be able
to calculate data faster that ColdFusion.
4. See the question/answer below on dynamically generating
fast, static HTML in place of CF pages.
Larry C. Lyons, ebstor.com
I want to generate a series of static HTML files
dynamically, based on some CF templates.
How can I have CFFILE read a template, insert CF variables in the
appropriate places, and then save the output results to a static HTML file?
A lot of people realize how fast HTML files are without CF! However, you can use CF to dynamically
“write” static HTML files themselves!
For example, if you wanted to make a static HTML page for every
record in your publications table, you might do something like the following:
Make a template with CF variables that would
display your fields from your publication table.
Run a query to get your publication
table. Let's say there is an ID field
for each pub called "Book_ID"
template into a CF variable:
<CFFILE action="READ" file="Pub_Template.cfm"
Loop over the query, writing a file for each
record in the DB.
<CFSET MyPub =
<CFSET Pub_FileName =
file="#Pub_FileName#" output="#MyPub#" >
You might want to first delete all files in
the directory you are writing to, or check for existing files before writing,
so you don’t get errors, or delete files unexpectedly.
You could run this code on a schedule, and
“re-generate” your web site once a week or once a day, keeping it up to date
and very, very fast. Use the
<CFSCHEDULE> or the NT scheduler (AT command).
Taiyebali Zakir, Soza & Company
How can I encrypt and save passwords in my SQL Server table?
Use the Encrypt() function that comes with CF, or download one
of the many encryption tags from the Developer’s Exchange section of the
Allaire web site.
By the way, you don’t have to decrypt the password from the DB
to compare it! One the encrypted
password is saved, and the user is registered, the next time the user logs on,
simply encrypt the value from the form and compare it to the encrypted string
from the database. If you don’t provide
a decryption routine, then this allows you to have “one way” encryption where
the user’s password cannot be discovered, even by the system administrator.
Jimmy Jose, SETA Corporation
How can I attach multiple documents in one email?
CF Server 4 comes with an <CFMAILPARAM> child tag, just
for this purpose:
<CFMAIL TO="recipient" SUBJECT="msg_subject" FROM="sender">
<CFMAILPARAM FILE="file-name1" >
<CFMAILPARAM FILE="file-name2" >
Body of email text goes here….
Kathy Hillstrom, Lockheed Martin
Using CF 4.5.1, if I restrict the CFREGISTRY tag (in the
CF Administrator), then I can’t use the ColdFusion Scheduler. Is running the NT scheduler (AT) the only
This stumped the CF Doctor, even though methinks the
answer is “Yes, use the NT scheduler.”
Email me with your opinions about this problem, and any other feed back, to:
CF Doctor is Douglas Smith who is the web/database architect for TeraTech.
Michael Smith is president of TeraTech http://www.teratech.com/
a 12-year-old Rockville, Maryland based consulting company that specializes in
ColdFusion, Database and Visual Basic development. TeraTech runs the MDCFUG and recently organized the two-day,
Washington, DC-based CF2001 conference that attracted more than 150
participants. You can reach Michael at [email protected]