Serving media using aliases and SetHandler with Apache, Railo and Tomcat

While converting a site from Adobe Coldfusion to Railo that was using the alias and SetHandler pieces in apache. I was having issues with getting it to behave the same as in ACF. In ColdFusion using the Jrun connecter the alias is treated as if it's simply a subfolder of the main site so there is nothing really special that needs to be changed. I can see this becoming an issue with ACF when 10 is released and running on tomcat. In Railo on Tomcat using aliases poses a couple of problems, Tomcat wants to treat aliases as separate contexts, though there may be times when this is desired if you are wanting the alias to maintain the appearance that you are simply navigating to a subfolder in your main site you will need to adjust a few settings to get the desired behavior.


Railo Server Settings

For a project recently have been working on need to be able to add settings to my Railo server during installation. Being that there is actually multiple sites we needed to be able to add these settings to the server settings for Railo.

after a brief Google search not yielding many results, was able to search around the machine and locate the server context and find the configuration files that needed to be modified.

  • Railo Server Context Location
  • {Railo Install Directory}\lib\railo-context\context

Hope this helps any one who is looking for the same thing, and as a reminder for me for the next time I need it and I forget where its at.

Moved to AWS

10 years a go I worked on a site for a local company. This month I officially am off that project. With that the server that the site was hosted on and this one as well will be going away.

With that I opted to move to Amazon Web Services EC2 server to host my blog and a couple of the other sites that I work on.

I am currently working on writing up the procedures I used to get every thing up and running on AWS. I am sure there are a few write ups on how to set up Apache + Railo + MySql on AWS but I hope to come from a plain ubuntu install to everything working together.

I also plan to being to post more with most of it being on the Jquery/Railo ORM side of things as I being working on a new project.

Sorting methods in your components

Working on a project where I need to compare the functions in one components to insure that they were present in another and the logical way to accomplish this was to get my methods sorted into alphabetical order.

It's not much code and pretty self explanatory as to what its doing so I am not going to explain it line by line. Feel free to ask questions if you have any.

view plain print about
2<cffile action="read" file="physical/path/to/your/component" variable="cfc">
4    function getMethods() {
5        regex = '<cffunction((\s+\w+(\s*=\s*?:".*?"|.*?|[^">
6        start = 1;
7        length = len(cfc);
8        methods = structNew();
9        do {
10            method = {};    
11            matches = REFind(regex,cfc,start,"true");
12            if(matches.pos[1]+matches.len[1] NEQ 0) {
13                name = getName(mid(cfc, matches.pos[2], matches.len[2]));
14                method[name] = mid(cfc, matches.pos[1], matches.len[1]);
15                structAppend(methods,method);
16                start = matches.pos[1]+matches.len[1];
17            } else {
18             start = length;    
19            }
20        }
21        while (start NEQ length);
22    return methods;
23    }
24    function getName(s) {
25        var i = 1;
26        for(i=1;i<=listLen(s," "); i++) {
27            if(find("name",listGetAt(s,i," "))) {
28                name = listGetAt(s,i," ");
29            }
30        }
31        name = replace(name,"name=""","");
32        name = replace(name,"""","");
33        return name;
34    }
36<cfset methods = getMethods(cfc)>
37<cfset sorted = structSort(methods,'textnocase','asc')>
40<cfloop array="#sorted#" index="function">

run the code above and view the source to view the results. May look at making this a Coldfusion Builder Extension at some point.

Using SQLite with Railo

I was starting a small project that requires the use of SQLite, and the number of resources for where to put everything and how to connect up railo and the SQLite jar.

First thing you need to do is head off to and download the latest SQLite jar. After you download the jar file to put it into the lib dir of your rail/resin install. For other server engines (Tomcat/glassfish) where you put the jar file may vary.

Restart Railo so the changes take effect.

Once that is in place log into your Railo web admin and select datasources. Scroll down to the section where you create the data sourece and enter the name for your datasource and select JDBC - Other for the type.


Endless scrolling with jQuery and Coldfusion using ORM

Been on Facebook, Twitter or any number of sites that loads data as you scroll? I would bet that most of you have. lets show you how to set up your site to load data inline while the user scrolls down the page.

The first steps is to get the initial set of data and a record count for the entire dataset that is going to be loaded up. This is pretty much standard Coldfusion nothing fancy.

view plain print about
1<cfset numRecords = ormExecuteQuery("select count(*) as total from entries")>
2 <invalidTag>
3    //Will discuss the script section below.
4 </script>
5 <cfoutput>
6    <cfset entries = entityload("entries",{},{maxResults=10,offset=0})>
7        <div id="entries">
8            <cfloop array="#entries#" index="e">
9            <div class="entry">
10                <h3 class="title"><a href="#e.getUrl()#">#e.getTitle()#</a></h3>
11                <div class="content">#e.getContent()#</div>
12            </div>
13            </cfloop>
14        </div>
15 </cfoutput>


Auto Completing values from Multiselect Box

As Web Developer we are always striving to give our users an experiance that will make the technology they are using as transparent as possible. Not having to put a lot of thought into how to use the interfaces we create and just using that technology to interact with the web. As always there are those time where there is soo much information on a page or that the user has to interact with that things be come trouble some.

One of those areas is often the select box. Even though it has a nice tidy little package we as developers some time like to cram a little bit too much in there then add to that a user needing to select multiple values and you end up leaving the users to sort through a lot more information then is needed.


Pinned sites with Internet Explorer and self signed certificates.

We have all seen the screen whether its Chrome, FireFox or Internet Explorer when we visit a web site with Self Signed certificates or where the browser things there is something not right. In Chrome you get the bright red screen, in FireFox you get the crossing guard image and in IE the Shield. If it's one of your own sites you just hit the button that says continue on and ignore the message.


Using the IN Operator with OrmExecuteQuery

Yes, another ormExecuteQueryEntry! I promise my next article will not have anything to do with ormExecuteQuery. While I was searching for an unrelated issues I was coming across posts where people were having issues using the IN operator with ORM. Here is a quick breakdown of how to format the query.


Using parameters with ormExecuteQuery and Railo

Though the new ORM functions in Railo are great there is often times you need just a little more than matching one or two columns exactly when you're getting data. When you reach this point it's time to bring in ormExecuteQuery as a method of gaining that little bit more of control over getting your data. Though there is more to ormExecuteQuery but I want to discuss how to use the conditional parameters of your where clause.

Though you could just insert the parameters directly into your query, we all know that that is not safe and is how SQL Injection attacks occur. In fact I am not even going to show that as we don't even want you to think about doing it that way, and since cfqueryparam cannot be used here we need to find another way to keep our system secure but get the data we need.