ColdFusion 8 Launch Event in New Zealand

ColdFusion 8 is being at the NZ CFUG meeting on 8 August, here in Auckland.
There are going to be a couple of presentations on the new features CF8.

One lucky person will win the grand prize — a CF8 license! All because s/he was there at the right place and at the right time.

For more details, head over to the CFUG site.

See you there!

ColdFusion-based sites in New Zealand

Recently the New Zealand ColdFusion user group (NZ CFUG) added a page in its Google Groups site listing various New Zealand website that use ColdFusion.

When I saw that, I was curious to find out how did they rank vis-a-vis each other in terms of number of pages of the sites listed in Google.

So I wrote a small ColdFusion application to shoot off to Google and find out the number of pages in any given site. (More on this app in another blog that I’ll be posting soon.)

I fed the application the list of all the 21 sites listed on the NZ CFUG site, and here are the results.

Number of pages indexed in Google for ColdFusion-based sites in New Zealand
Site
Pages
newzealand.com
390,000
Auckland University
159,000
New Zealand Herald
106,000
Massey University
55,000
Book a Bach
18,400
Sky Television
12,300
Foundation for Research, Science and Technology
11,100
Auckland Regional Council
7,220
Cuisine Magazine
6,150
Regency Duty Free
3,830
allblacks.com
3,070
Ministry of Education
1,210
ShadoCMS
976
Genesis Energy
555
rockcote.co.nz
350
altex.co.nz
206
skycity.co.nz
78
boatelectronics.co.nz
61
express-it.co.nz
25
polycut.co.nz
22
robinrive.com
5
redcross.org.nz
2
pizzahut.co.nz
1
emeasure.co.nz
1

The results were quite interesting.

  • newzealand.com is huge — 390,000 pages. They do have a lot of content, and the fact that the site runs in multiple language helps.
  • The sites for the two large universities in New Zealand — Auckland University (auckland.ac.nz) and for Massey University (massey.ac.nz) — also had quite a few pages indexed on Google. But of the two, Auckland University had almost triple the number of pages than Massey University.
  • New Zealand Herald is a large site for the New Zealand Herald newspaper. I would have thought that they would have more number of pages than 106,000. Being a newspaper, the site adds a ton of content everyday. But I guess they need to optimize their site for getting indexed into Google.
  • Of the NZ CF sites listed as of today on the NZ CFUG site, the three of the top four large sites seem to be running on ShadoCMS. Time for a disclosure — I work for Straker Interactive who develop ShadoCMS. But the intention of this blog is not to plug for ShadoCMS!
  • Book a Bach is a site for making online bookings for holiday homes in New Zealand. Obviously they have done things nicely and in Google friendly way.
  • The website for the Sky City group has less than 100 pages indexed on Google. And it is quite surprising given that the actual site seems to be quite large (runs on ShadoCMS as well).
  • Pizza Hut site is only listed once in Google. I guess they don’t need anything else as long as they get found by the search keywords “pizza hut new zealand”, which they do!

I’ll post updates on this blog as more CF sites are added the NZ CFUG site.

Disclaimer: Please keep in mind that these are valid at the time of this blog entry and are based on the sites listed on the NZ CFUG site as of today. Also, this is based on one criteria only –number of pages indexed in Google for a site website URL.

Instantiating a CFC in a directory with a period (.) in the directory name

The question is: how do you instantiate a ColdFusion Component (CFC) that exists in a directory which has a period (.) in the directory name.

The CFC I wanted to invoke lived at c:\webroot\components\2.1\math.cfc.

Instantiating it with the full package path “components.2.1.math“, threw an error.

I tried using “/” as well as square brackets in the package path, but both threw ColdFusion errors.

The answer was to create a ColdFusion Mapping (through the ColdFusion Administrator) to the folder in which the CFC lived.

So I created a mapping called “/version_2_1/” and pointed it to “c:\webroot\components\2.1\“. This way the full package page of the CFC was “version_2_1.math“. And this is a seen as a valid path by ColdFusion.

So life is sweet for now.

However, I’m still not sure what would one do if one didn’t have access to CF Administrator.

Do let me know if you know of any other way.

Search Engine Safe URLs on ColdFusion MX 6

Today I needed to enable the server-level search engine safe (SES) urls on a ColdFusion MX 6 server.

In the past I’ve referred to an Adobe technote for this. This technote shows how to accomplish this by adding a few servlet mappings to web.xml of the server.

I wanted to add the same mappings to a CF 6 server to enable SES urls. Howver, for some strange reason, the technote shows a screenshot of these mappings, which means that I can’t simply cut and paste them into my web.xml.

So here are the nodes for these mappings as “text” rather an “image”.

<!--If your J2EE server supports it, you can uncomment these.They are included to support Search Engine Safe (SES) URL types.Some servers (Tomcat, SunONE) don't support wildcard mappings-->
<!-- begin SES -->
<servlet-mapping id="macromedia_mapping_11">
 <servlet-name>CfmServlet</servlet-name>
 <url-pattern>*.cfml/*</url-pattern>
</servlet-mapping>

<servlet-mapping id="macromedia_mapping_12">
 <servlet-name>CfmServlet</servlet-name>
 <url-pattern>*.cfm/*</url-pattern>
</servlet-mapping>

<servlet-mapping id="macromedia_mapping_13">
 <servlet-name>CFCServlet</servlet-name>
 <url-pattern>*.cfc/*</url-pattern>
</servlet-mapping>
<!-- end SES -->
</pre>

Add these to the web.xml of your server, restart the server instance, and the any application (like BlogCFC) that makes use of search-engine safe urls will start working nicely.

Installing Apache Derby Database on ColdFusionMX 7.0.2

I recently re-discovered Apache Derby, a Java-based database that seems like a promising alternative to MySQL. I downloaded it a few months back but for some reason or the other never persisted with it. Anyway, this time around there were other factors so I went through the motions of understanding how it works and setting it up.

My main goal was to get Derby to work with ColdFusionMX. And after a few minutes of looking at the documentation it was fairly easy to figure out what I needed to do. Derby can be installed in two environments:

  • Client/Server: where it runs like any other RDBMS like MySQL Server, MS SQL Server or Oracle. External applications/clients like ColdFusion applications can connect using JDBC/ODBC drivers (or any other mechanism). When Derby runs in client/server environment, multiple applications can access the Derby server over network
  • Embedded: Only a single application can access the database at a time. The reason why it is called “Embedded” is because Derby starts within the instance of an application in which it is embedded. Network access is not available when Derby runs in embedded enviornment.

I chose the embedded option. It seemed the easier of the two, seemed to satisfy the reasons why I wanted to use it (as an alternative to a MySQL database for a sample application I was working on).

And easy it was.

After downloading zip file for the latest release (10.1.3.1), unzipping it in a folder, I copied lib/derby.jar into the /WEB-INF/lib directory of the ColdFusionMX server instance. I then restarted the ColdFusionMX server, and theoretically the Derby database server should now be “embedded” in the ColdFusionMX instance.

To test that I logged into ColdFusionMX administrator, and setup a datasource with the following details:

Datasource Name : derbyDemo
JDBC URL: jdbc:derby:derbyDemo;create=true
Driver Class: org.apache.derby.jdbc.EmbeddedDriver
Driver Name: Derby Database Driver
Username: [left this blank]
Password: [left this blank]

Notice the “create=true” attribute passed as part of the JDBC url. That tells the embedded Derby database server to create the database in case it doesn’t exist. Upon clicking submit (and waiting for a few seconds), ColdFusionMX administrator informed that the datasource was successfully setup. Voila!

The next step was to create some tables, add some data and query the database. As Derby does not ship with a visual client tool, I wrote a 1-minute Derby Query Manager 🙂


<html><head><meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /><title>1-Minute Derby Query Manager</title></head>

<body>

<cfparam name="form.sql" default="">

<cfoutput><h2>Query:</h2><form action="index.cfm" method="post">   <textarea name="sql" cols="60" rows="10">#form.sql#</textarea>   <br/>   <input type="submit" name="btnQuery" value="Query!"/></form></cfoutput>

<cfif len(trim(form.sql))>   <h2>Results:</h2>   <cfset myquery = queryNew("")>   <cftry>      <cfquery name="myquery" datasource="derbydemo">         #preserveSingleQuotes(form.sql)#      </cfquery>      <cfcatch type="database">         <cfdump var="#cfcatch#">      </cfcatch>   </cftry>   <cfdump var="#myquery#"></cfif>

</body></html>


Using this, I issued the following three queries to create a database, populate it and query it.

<!--- Create a table called products ---><cfquery name="qCreate" datasource="derbyDemo">   CREATE TABLE products (   itemNumber INT NOT NULL,   price DECIMAL(5, 2),   stockDate DATE,   description VARCHAR(128)   )</cfquery>

<!--- Insert some dummy values ---><cfquery name="qInsert" datasource="derbyDemo">   INSERT INTO products(itemNumber, price, stockDate, description)   VALUES (4, 29.95, '2006-02-10', 'Male bathing suit, blue'),   (5, 49.95, '2006-02-20', 'Female bathing suit, one piece, aqua'),   (6, 9.95, '2006-01-15', 'Child sand toy set'),   (7, 24.95, '2005-12-20', 'White beach towel'),   (8, 32.95, '2005-12-22', 'Blue-striped beach towel'),   (9, 12.95, '2006-03-12', 'Flip-flop'),   (10, 34.95, '2006-01-24', 'Open-toed sandal')</cfquery>

<!--- Query the table and dump results ---><cfquery name="qGet" datasource="derbyDemo">   Select *   From products</cfquery>

<cfdump var="#qGet#" label="Derby Database Test Results">

All worked as expected. The first query created a table, the second populated it, and the third queried it and retrieved records. Wonderful! I love it when technology works as one expects.

If you want to a slightly more robust tool, Derby ships with a command-line, interactive tool called, ij (in the frameworks/embedded/bin/ directory). There is also a third-party application called Squirrel SQL Client, a Java-based UI to work with various database platforms, including Apache Derby.

I’m in the process of writing a little more useful Flex 2.0 based tool at work. I’ll post a link to it when I’m done.

All in all, it was very easy to get Apache Derby to work with ColdFusionMX. Once I have a decent Flex-based tool, I’m quite sure I’ll be using much more of Derby in the projects I work on.