Archive for the ‘ColdFusion’ Category

Or – Resolving the ColdFusion Content is not allowed in prolog Error.

If you’ve tried to consume web services with ColdFusion, you may have run into this issue when attempting to use the returned XML. I’ve seen this crop up when simply pulling in an RSS feed as well. Often there are some strange characters at the beginning of the XML response. We can see the problem if we use Firefox to browse to the Authorize.net web service:

Firefox BOM error
Continue reading ‘Cleaning up those funny characters on an XML web service result’ »

When building an application that uses an Application.cfc file, many times the OnApplicationStart() method is used to initialize Application scope variables.

Since this method is only called once until the next server restart, its safe to set your Application variables here without using cflock tags. A common implementation may look like this:

<cffunction name="onApplicationStart" returntype="boolean">
	<cfset Application.dsn = "myDSN">
	</cfset><cfset Application.smtpserver = "localhost">
</cfset></cffunction>

But what happens when you need to change one of those variables? For example if you change the Application.smtpserver value to “newhost.com”, and save the file, Application.smtpserver will still be set to localhost. Restarting the ColdFusion server will force the OnApplicationStart() method to be called again, thus loading in your new value, but that is a little drastic.
Continue reading ‘Providing feedback when forcing a refresh of the Application scope’ »

Tonight I gave an “Intro to ColdFusion” presentation at the Omaha Dynamic Language Users Group. As promised, here are the links from my Resources slides. The full presentation is also available: Open Office (1194Kb), PDF (560Kb)

Tonight we had Adam Lehman from Adobe speak to our CFUG about Scorpio. It was very impressive! They’ve truly done an excellent job at making this a ‘must have’ upgrade. The UI tools, server monitoring, image manipulation, presentation generation, the list goes on. It was just one amazing feature after another. And I can finally use var++ to increment a variable! I have been waiting for this since I started using ColdFusion 4.5.

You can find the Scorpio Tour events on Adobe’s website: http://www.adobe.com/products/coldfusion/events/

I am currently working with a client that sends large amounts of mail using ColdFusion. They are having a few problems, and I am going to be doing some optimizations to improve their mail delivery. One of the things we are going to do involves monitoring the number of messages in the ColdFusion spooler directory that are waiting to be handed off to the SMTP server. This involves looking at the files in the ColdFusion spool directory. I did not want to hard code the path to the spool directory, because it may change between production and development machines, and the path may also change when ColdFusion is upgraded.

It is possible to find the spooler directory programatically. My first thought was to look in the adminapi. No luck there. But digging around in the ColdFusion ServiceFactory java class lead me to my answer:

<cfset sFactory = CreateObject("java","coldfusion.server.ServiceFactory")>
</cfset><cfset MailSpoolService = sFactory.mailSpoolService>
</cfset>

<cfoutput>#MailSpoolService.getSettings().spooldir#</cfoutput>
Continue reading ‘Programatically finding the ColdFusion installation and mail spool directories’ »

I recently wrote a routine to export a client’s newsletter subscribers as a CSV file. There are a little over 7000 records in the database now and that is expected to increase at a steady pace. I have been wanting a good reason to reach into Java and do some fancy string manipulation, as I’ve read it can be quite a bit faster than in native CFML. So this looked like a perfect chance to try it. Here’s my first take in plain old CF. I had some additional quote and comma checking in there but I’ve left it out for readability.
Continue reading ‘Using the Java StringBuffer class ColdFusion – faster CSV files’ »

Unless you’ve been living on a desert island for the last year, you’ve probably heard that you’ll need to upgrade ColdFusion’s JVM (java virtual machine) before March 11th 2007. Thats when daylight savings time takes effect this year. Since the dates have shifted in 2007, anything that is aware of daylight savings time will require an update. This includes your operating system (Windows, Linux, OSX, etc.), and Java since it has its own internal timezone tables.

And if you use NTP (network time protocol) to set the time on your servers from an internet time server, don’t think you’re immune. NTP simply syncs your internal UTC (universal time) clock with a UTC clock on the internet. Your timezone tables then determine your actual local time, based on your UTC offset, which changes during daylight savings time.

Updating ColdFusion’s JVM is very easy. The version of java that ColdFusion ships with is 1.4.2_09. You can see this if you login to your CF Administrator, then click on SYSTEM INFORMATION at the top of the page.

CF Administrator - Java details
Continue reading ‘Upgrading the ColdFusion JVM – on Linux and Windows’ »

I was working on converting an application from ColdFusion 5 to CFMX 7 last week, and ran into some problems converting cfgraph (CF5) to cfchart (CF7). The graphs that looked nice in 5 weren’t coming out so good in 7.

Original chart in CF5, using the CFGraph tag:
CF5 chart

How the chart looks after converting to CFChart in CF7
CF7 chart
Notice the problem with the y-axis labels.
Continue reading ‘ColdFusion CFChart woes – converting from CFGraph’ »