Volume VI (Apr 2001-Dec 2001)

Why it's wrong to use application.dsn in your templates, and what to do about it

Posted: 6/1/2001; Updated 6/25/2001

This tip is so long that it's really deserving of it's own page.

Finding a Good CF Hosting Company

Posted: 6/8/2001

Be sure to also see the more recent question, below, How do I know if I'm paying the right price for a hosting provider?.

I was recently asked if I could help a reader find a good CF hosting company (someplace to hold his CF pages, rather than running his own web server) in the Northern California area.

I replied: Have you visited Allaire's site, which offers a list of hosting providers? Go to allaire.com, choose "partners" on the top nav bar, choose "hosting partners", then choose "find a partner" on the left nav bar. On the search page, choose USA, CA, and pick "dedicated Allaire hosting" under "focus". There were 72 meeting that criteria, as of today.

I tell you this, rather than just the URL, so that you might become more familiar with resources like this, which Allaire does indeed provide to help us developers. It's good to know about them.

Also, note that there's often benefit to looking outside your own local area. There are many regional and national hosting services. Also, a local company in a city far from you may offer better service than any local or national chain. Considering that you do nearly all your interaction with the site electronically, it really doesn't matter where the site's hosted (I've had sites hosted in Australia, Texas, and Virginia, and none were local to me.) Of course, there is the issue of support calls, but even then a local company may offer an 800 number.

One of the services I use, Minerva Network Systems, in Chantilly VA, does this. There are also hosting firms that aren't recognized national names but do focus on CF hosting (such as cfhosting.com", who I also use) that are worth a close look.

If, by chance, you've been there and still want more hosting partners, there are other resources listing them, including:

and even a place that ranks them at: http://cfhostingsurvey.com/

although as of today, 6/8/2001, I saw not means by which to add new companies nor to rate those listed.

Also, the January 2001 issue of ColdFusion Developer's journal was a hosting special issue. Among the articles listed on the CFDJ site as being available for public access are:

Test Your Code Changes with the CFML Syntax Checker

Posted: 6/15/2001

Did you know that there's a syntax checker for CF? It came out in Release 4, as was documented elsewhere in this tip repository in a set of tips from 1998 (3 tips, perhaps a little dated now, starting here).

Anyway, if you're not using the syntax checker, you're missing out on a great tool. While it came out originally to help folks making the conversion to Release 4, I fear it's being woefully underused for a much more valuable purpose.

How often have you changed some code in a complex application, perhaps in a page that's 5 screens into the app after doing a login and some sort of DB search or creating a shopping cart, etc.

The problem is, you don't always want (or have time) to fully test the code changes. You trust your fingers, upload the code, and figure your error handler (or worse, the user) will report any problems. It's an understandable plight and choice, but maybe not the best one, especially if you know that AT LEAST you could run the syntax checker against your code.

It's not a real substitute for testing, since it doesn't confirm that your logic is correct or that the HTML or other content you create is correct (or valid, itself). It just checks that the CFML code would compile if it were executed. And that's not a bad tool to have in your bag.

And it's installed when you install CF server. The challenge is just knowing where to find it. You can find the syntax checker via a link off the "welcome to CF" page. If you have CF installed on your own machine, that's

That will actually lead you to a page (, which is a web page that offers a form to do the syntax checking. You point it to the directory holding the template (or templates) to check, and off you go.

Note: before you assume that you can just point to a remote CF server by replacing the address in the URL, take note of a couple things in the tip below.

Some people wonder if this is some sort of custom tag that you call. Nope, as the URL above shows, it's just a CF application (cfmlsyntaxcheck.cfm) located off your webroot (or wherever your CF docs were installed) in a subdirectory called CFDOCS/cfmlsyntaxcheck/.

Note that the form itself (cfmlsyntaxcheck.cfm) is an unencrypted/unencoded file, but the page doing the checking itself is encoded. Still, you may be able to study the form to find a way to use the checker in a more customized way.

Using the syntax checker on a remote server

Posted: 6/15/2001

The tool as installed is designed only to allow checking of files on a local workstation (from the address specifucally). You may assume that you can just point to a remote CF server by replacing the address in the URL, but it's not that simple.

First, if you look at the form in cfmlsyntaxcheck.cfm, you'll see it's got some code that limits the tool to be run only if it's called from a local workstation. You can change the line: <CFSET isAllowedToExecute = (CGI.REMOTE_ADDR IS "")> which says the remote_addr (the IP address of the calling user) must be set to the localhost ip address, to either just let anyone run it, by making it: <CFSET isAllowedToExecute = 1> or make it so that only people with a given UP address can run it, as in <CFSET isAllowedToExecute = (listfindnocase(",youripaddresses",CGI.REMOTE_ADDR)> replacing youripaddresses with a comma-delimited list of ip addresses as appropriate. Just be sure not to introduce any spaces before or after the ip addresses, since the listfindnocase is sensitive to that.

Also, keep in mind that if you do run it on a remote server like this, since the page runs where your CF server is located, the code it's checking must also be on that server (or accessible via a drive it can reach).

That is, the form expects to be told where to find files to check, relative to the server doing the checking.

So you can't use it to check code on your local workstation, unless you have some sort of mapped drive from the server to your workstation (note that I DON'T mean a mapped drive from your workstation to the server). We're talking about whether the server can see your workstation files.

Then again, if you have code on your local workstation, you probably are running a local copy of CF and should run the syntax checker there, via the URL pointed out in the first tip above.

Things you may not know about what's new in Release 5

Posted: 6/16/2001 Updated: 6/28/2001

By now most have heard about the many new features in Release 5 of CF, but often focus is placed on a handful of key new features. Some get lost in the din.

Rather than list any particular examples here, just be sure you've looked at all the resources available to tell you what's new. Some may be obvious, some not so:

And of course, there are all the manuals, some of which are new or enhanced, at http://www.allaire.com/developer/documentation/coldfusion.cfm. This page also lists links to those above.

You may also want to see the Performance Brief.

One little thing that I'd not seen discussed anywhere till I noticed it in the Tag Insight for CFFORM, there is a new PRESERVEDATA="yes/no" option, which seems to provide an automated mechanism to pass the data from CFFORM fields (CFINPUT, CFTEXTINPUT, CFSELECT, CFSLIDER, CFGRID, CFTREE) back into the CFFORM when the action page and form page are the same or the action page has a form with the same-named form fields. Interesting idea. It is indeed documented in the Release 5 CFML Reference and Developing Web Apps books.

Why you should use CFLOCK around any Verity tags, or how two tags on the same page can run at the same time

Posted: 6/28/2001

This tip is so long that it's really deserving of it's own page.

How do I know if I'm paying the right price for a hosting provider?

Posted: 6/28/2001

This question is similar to, but different from, the related tip posted above, on Finding a Good CF Hosting Company. Be sure to check that out as well.

Another person recently asked, "I'm considering hosting with company x. They want to charge me $149 a month. How do I know if that's a good price?"

The answer is, it's really hard to say whether 149 is a lot to pay for CF hosting. There are several variables that could influence that evaluation: are they guaranteeing some level of support? free? 800 number? 24x7? Is it good quality service? Is there a mechanism for reporting and tracking problems? Do they track problems occurring on the server and keep you informed of how they're handling them?

Are they guaranteeing some quality of service? Some hosting providers throw 40 or 50 CF applications on the same box and just cross their fingers.

Are they providing some unusual quantity of disk space? email addresses? SQL server databases? Verity index collections, etc? Have they installed some special custom tags you can use? Do they provide web trends reporting?

Are they doing more than just hosting the site? Are they building or managing any part of it?

Are they providing some unusual service to assist developers? An interface for administering datasources, etc? Advanced Security, allowing protected access for you to your own things so that other developers can't get to them? Do they force developers to lock access to all shared variables? If not, someone else's bad code on your server could bring down your site.

Do they have a problem with you doing a given volume of outgoing email from CFMAIL? Have they set up any alternative process for sending large amounts of mail (I don't mean spam or bulk email, but maybe you offer a service where you want to send information to your membership of several hundred at least weekly. That could tax the mail server.)

Are they providing SSL-enabled secured area for your site? and installing a certificate of your own, or forcing you to use theirs?

Do they offer the latest release of CF? and of ODBC drivers, etc?

There are services that are as low as $20 a month, and others in the hundreds. It's not always that you get what you pay for. It's just that there are so many variables, so it's hard to say if you're getting a good price or not.

Again, see the tip above: Finding a Good CF Hosting Company. While that's not the same question, it may be worthwhile looking at the answer.


Do I really need to lock access to shared scope variables?

Posted: 6/28/2001

This question is similar to, but different from, two related tips above, on Why application.dsn is bad and Why you should use CFLOCK around any Verity tags, or how two tags on the same page can run at the same time. Be sure to check those out as well.

Someone asked, "I'm confused about locking of variables. Would it be necessary to do something like this?"

<CFLOCK .....>
Yes, you would need a lock, though I don't know if I'd recommend doing what you indicated you were going to.

It simply doesn't matter how you use the variables (within or between tags). If you reference a shared scope variable in any way, then it should be locked in order to prevent conflicting simultaneous access to that variable by another process.

The problem is, while one template is being executed that's reading a variable (as in your example), another template (or another instance of the same template, given CF's multi-threading capabilities) may execute and try to update that variable. Or two templates may try to update a variable at the same time. The challenge is about whether there are writes to a variable taking place while another template is either reading or writing that variable (or vice versa).

How can two templates update the same variable simultaneously? In the case of application or server variables, it's easy to see how it can happen. Just another user running at the same time can cause the problem. Session variables are more subtle: consider that a browser can request multiple templates at once (browsers try to open many threads at once for a given page). Or multiple instances of a given template can be executed at once, perhaps from within a frame or by way of another instance of a browser running on a given user's workstation.

The answer then is to lock (with a READONLY type) any attempt to read the variable, and lock (with an EXCLUSIVE type) any attempt to write to it.Of course, in this example, the lock for both the reads and writes to any session variables should be done with a SCOPE of "session". And it's not good enough if only some of the code in an application does it. If any other code running on the server accesses the same shared variables without a lock, the potential for conflict (and server instability) arises again.

Finally, be careful about locking it the way you have proposed, wrapping multiple lines of code in a LOCK. Try to lock as few lines of code as possible, so as not to hold the lock for too long. In your case, if the inside of the IF did a query or some other long process, you'd be holding the lock a lot longer than you should (and the TIMEOUT attribute of the CFLOCK tag has nothing to do with how long you will hold the lock: it's how long you're willing to wait for the lock someone holding that's blocking your attempt to lock the variable, such as if you want to write it and another process is holding an extended readonly lock, or vice-versa).

A common solution to this dilemma of needing to lock just the variable, and not some longer set of code that uses the variable, is to assign the shared variable to a request scope (which is not shared, but is better than a local scope in that it can be accessed by custom tags called by the page).

Be careful, though, if you try to copy a single variable that's composed of a structure to another variable, or if you try to copy an entire scope (like all the session variables for a user) to another variable, such as a request variable. Doing so simply makes a copy by reference, or an alias, of the structure rather than a copy by value (or a clone). So the potential for conflicts still exists (and is kind of nasty, because even if you have the administrator option set to enforce locking, it doesn't detect this sort of unlocked access by a variable holding an alias of a shared variable. To create a clone (rather than an alias), use the duplicate() function rather than a simple assignment.

OK, so you didn't ask for all that, but it kind of spilled out of my brain. Hopefully it's helpful. If anyone would offer clarifications or corrections to any of it, please do let me know.


Getting Studio to Enter Tags and Attributes in Uppercase

Posted: 7/2/2001

If you prefer to use uppercase for tag names and attributes, you may disappointed that when Studio inserts attributes chosen by the tag insight or tag editor feature, it enters them as lowercase. This is a setting that you can control, however, with options>settings>HTML>lowercase all inserted tags.

There's still a chance that you may not like the results. If you aren't careful and type the tagname in lowercase, then studio will uppercase the attributes but won't change your tagname case (which makes sense, technically, since studio didn't "insert" the tag for you, you typed it).

What's also perhaps confusing in this situation is that the tag completion feature also respects the case of the opening tag, so if you typed it as lowercase, Studio will make the closing tag lowercase (the option doesn't say "uppercase all inserted tags", it says "lowercase" them. So Studio is doing what it's supposed to do if the option is off. If you want the closing tags to be uppercase, then the opening tag must be as well. Just get used to typing opening tag names in upper case. Think of it as "priming the pump". The tag completion will take care to make the closing tag be upper case.

How might you get the opening tag to be uppercased even though you're typing in lowercase? Well, there is a trick that may work for you. If options>settings>editor>tag insight has its delay setting at 0 seconds, then while you type in the tag name, Studio does offer a list of tagnames that match what you're typing. If you select one of these (hitting enter if it's selected the one you want, or using the down arrow key or mouse to select another from the list), then it will indeed enter it in uppercase (assuming the "lowercase inserted tags" option is turned off.

Tips Contents:

| Home | ColdFusion | Articles | Presentations
| User Groups | Other Resources | Press Releases | Company

© 1998-2024, Charles Arehart, SysteManage
Our Practice Makes You Perfect