Entries Tagged as "Railo"

Railo tip: store complex data by using serialize(data)

Railo has this great function, which is my all-time favorite: serialize(). What it does, is converting (almost) any data to a string.
Now if you use the evaluate() function with that string, then the original data is rebuilt again!

So, let's say you have a structure with multiple nested queries and strcutures, and you want to save this data for debugging. Then you only have to serialize() it:

<cfset myDataAsString = serialize(myComplexDataObject) />

Not only can you use this on structures, arrays, and query objects, but you can even serialize CFCs. The variables scope inside the cfc is also serialized, so you will get a completely accurate object back.

Some examples of serialized data

This is the component test.cfc, which has 2 variables inside, test and test2:

evaluateComponent('test','6ad49215baf34832c9c00177d97ef513',struct(),struct('TEST':1,'TEST2':2))

This is a structure with 2 queries inside:

{'OTHERKEY':query('othercol':['pete','philip','paul'],'othercol2':[3,6,2]),'MYKEY':query('col1':['abc','xzx','dfdf'],'col2':[6,23,59])}

As you can see, it doesn't take much space, and is even human-readable.
Did you also notice the functions struct() and query() inside the serialized data? Those are actually Railo built-in functions. But that's for another Railo tip ;-)

Now, if you want to use this data again, you can just simply call evaluate() to get the original data back:

<cfset myData = evaluate(myDataAsString) />

I hope you now share my enthusiasm on this amazing function :-)

No Comments

Getting cgi.redirect_url in Railo on tomcat and Apache (404 redirects)

I suppose you are using a custom 404 page for your websites? If you are using Railo with Tomcat, and Apache as the frontend webserver, then you probably have noticed that you cannot determine the url that was originally requested (the 404 url). Normally, this info is available in cgi.redirect_url and cgi.redirect_query_string, but those are never set if you have this Apache+Tomcat setup.
Luckily, I found a way to retrieve those cgi variables!

1 Comment

Binary mod_jk.so file for mac OSX 10.6 (i386, Apache2.2, 64-bit, snow leopard)

I am not a linux wizard, absolutely not. I never want to be as well, because I think "smart people use easy tools". And all this make/configure/apt-get linux stuff is just soooo 1950. No need to leave comments if you disagree here; I know some people love this console stuff.

But anyway, I needed the Apache-to-Tomcat mod_jk module, so I could get my Railo install to work. I always used Resin + Apache, but the Railo default installation now uses Tomcat, so I wanted to make that switch as well.

It looked very simple to install mod_jk, but since there were no binary (compiled) releases of the module for mac OSX 10.6, it became a hell. Now, after some 7 hours of irritation, here it is: mod_jk.so.
I don't know if it will work on your mac as well, but I hope so for you...

Download mod_jk.so for mac OSX 10.6 Snow Leopard

4 Comments

Webserver-to-Tomcat VirtualHost copier for Railo! (v0.4.02, april 25, 2011)

If you use Railo as your cfml server, and use Apache or IIS as your main webserver, then you must have noticed that you need to add virtualHosts in 2 places. Once in the webserver, and once in Resin/Tomcat/Jetty, or whatever the JEE engine is you are running Railo on. This approach gets a lot of complaints, because people switching from Adobe Coldfusion (ACF) never had to do this. "It just worked".

So I thought of another way to make sure Railo knows what virtualhosts are available: by copying all virtualhost directives from Apache/IIS to the Railo server. ... Now I have only been able to test the parser code on 3 machines, while there are probably 100's of webserver configurations. So my question to you: please download and extract the code, and run test.cfm to see if your config files are correctly parsed.

43 Comments

Adding a Railo event gateway with <cfadmin>

Since I just figured it out, I thought it might be helpfull to others too:

<cfadmin action="updateGatewayEntry" type="server" password="server-admin-password"
startupMode="automatic"
id="name-of-the-event-gateway"
class=""
cfcpath="railo.extension.gateway.DirectoryWatcher"
listenerCfcPath="path.to.your.DirectoryListener"
custom='#{
directory="/private/etc/apache2/"
, recurse=false
, interval=2000
, extensions="conf"
, changeFunction="onChange"
, addFunction="onAdd"
, deleteFunction="ondelete"
}#'
readOnly=false
/>

<!--- remove the directorylistener --->
<cfadmin action="removeGatewayEntry" type="server" password="server-admin-password"
id="name-of-the-event-gateway" />

For all other documentation regarding the Railo event gateways, please see the Railo documentation wiki.

2 Comments

excess