WebDevelopment, ColdFusion, Railo, JS, Database and Tech-related by the Co-Founder and CEO of tunesBag.com

Showing posts with label railo. Show all posts
Showing posts with label railo. Show all posts

Tuesday, 4 May 2010

UrlEncodedFormat: Encoding space characters - plus (+) vs %20

I came across an issue with UrlEncodedFormat() today - signatures calculated by an CF9-based system always appeared to be invalid and as it seems ColdFusion is ignoring the standards when it comes to encoding of form posts (application/x-www-form-urlencoded).

The document describing the standard on W3 clearly states:

application/x-www-form-urlencoded

This is the default content type. Forms submitted with this content type must be encoded as follows:

  1. Control names and values are escaped. Space characters are replaced by `+', and then reserved characters are escaped as described in [RFC1738], section 2.2: Non-alphanumeric characters are replaced by `%HH', a percent sign and two hexadecimal digits representing the ASCII code of the character. Line breaks are represented as "CR LF" pairs (i.e., `%0D%0A').
  2. The control names/values are listed in the order they appear in the document. The name is separated from the value by `=' and name/value pairs are separated from each other by `&'.

When you perform an UrlEncodedFormat( ' ' ) on CF, it will return %20, the same call on railo will return "+" as described in the article above.

I solved the issue by simply replacing %20 with +.

Thursday, 20 August 2009

Setup Mac OS X + Apache + Railo

A fews days ago I upgraded to a Macbook Pro and I already spent almost two days on reinstalling software, copying documents etc etc (An upgrade is an opportunity for me to get rid of old software and ballast).

Today I started with the Apache / railo setup using a guide by Luid Majano (I had to download the Apple XCode Setup file (almost 1 GB) in order to compile the connector for Apache and reset the httpd to 32 bit instead of 64 bit).

Further problems I had to solve:
  • I wasn't able to access my files until I executed a chmod a+x on every directory in the path to the webroot (apache log [error] [client ::1] (13)Permission denied:)
Now it's working like a charm.

Thursday, 11 June 2009

Using the H2 database in ColdFusion

Railo is delivered with an embedded database called H2. The description on the homepage says:

Welcome to H2, the Java SQL database. The main feature of H2 are:

* Very fast, open source, JDBC API
* Embedded and server modes; in-memory databases
* Browser based Console application
* Small footprint: around 1 MB jar file size

Such a database fit's perfectly for a current task at tunesBag - the streaming servers should store some data on their own machines and mysql or postgresql just would be overkill for this task. So I decided to give H2 a look and it looks pretty nice.

On my local machine I'm working with ColdFusion 8 as well - the configuration to add H2 support for CF is very easy, just follow the following steps:

  • Download the latest version of H2
  • Drop the h2*.jar file in the WEB-INF/lib directory of your ColdFusion server (directory depends on your type of setup)
  • Restart CF
  • Add a new datasource
  • JDBC URL = jdbc:h2:file:%Path to Database file on your disk%
  • Driver Class = org.h2.Driver
  • Driver name = default
  • User name = sa

That's it - the files holding the data will be created automatically for you. Take a look at the H2 tutorial in order to find out more (e.g. server mode etc).

Wednesday, 29 April 2009

Railo - Compatibility issues with scopes (URL etc)

I'm migrating my development environment to railo and found some issues that affected my code.

One of the most important ones is that railo always references the scope name when you use URL, FORM etc no matter if a local variable with this name exists or not. To give you an example, run this code in CF and in railo:

<cfparam name="url.step" type="string" default="1" />

<cfset a_call = PrintURL( 'http://tunesBag.com/' ) />

<cfdump var="#a_call#">

<cfscript>
function PrintURL( url ) {
return url;
}
</cfscript>
To make railo behave the same way, you've to add a full reference to the function -
return arguments.url

In ColdFusion you'll see http://tunesBag.com as output, in railo the URL structure. Some further explanations concerning the scopes and this "bug" can be found here (Adobe Livedocs) and here (Railo Bugtracker)

Having fun with railo: CFQUERY supporting complex objects

I just came across a cool feature of railo - it's possible to set query columns to complex objects, e.g. a java object or a structure.

An example:

cfset q = QueryNew('data');
querySetCell( q, 'data', { firstname = 'John', surname = 'Doe' }, 1);

cfdump var="#q#"

You can access the structure by using q['data'][1]!

cool!

Important: This complex data won't survive a query of queries operation, in this case the simple classname will be shown in the column.

Tuesday, 6 January 2009

Railo - important path placeholders

I'm playing around with railo, a full featured alternative CFML engine and so far, I'm very impressed. During testing my existing applications with this new environment I had to add some custom mappings in the administration (by the way, there are two admin engines, the first one is server-wide, the second one just for the current webroot).

When creating these custom mappings, there are some very interesting path placeholders you can use:
{railo-web}: path to the railo web directory typical "{web-root}/WEB-INF/railo"
{railo-server}: path to the railo server directory typical where the railo.jar is located
{temp-directory}: path to the temp directory of the current user of the system
{home-directory}: path to the home directory of the current user of the system
{web-root-directory}: path to the web root
{system-directory}: path to thesystem directory

This way you can create mappings without using the full path to the directory - very cool!