Cross Platform Development Tips
The post I lost earlier today due to the power outage had a simple way of checking to see if your on a unix OS at runtime, and also some tips for writing cross platform coldfusion.
Running UNIX: #YesNoFormat(isUnix)#
Path Seperator: #pathSeperator#
The first line check to see if we are running unix by checking the first character of a path, if it begins with a /, then we are running unix. You can also do something like this
isUnix = server.os.name IS "UNIX" to set that variable, but I think my method may be a nudge faster because it doesn't deal with a synchronized scope (server scope), and it's checking a smaller string.
The next two lines find the path seperator using the same techinique, there are several ways of doing this as well, you can use the java System properties hashtable for instance. It should be pointed out that CFFILE and CFDIRECTORY will accept front slashes on windows, so one option is to just always use / to keep your apps cross platform, this can create messy paths sometimes however..
It is not very difficult to write cross platform applications in CFML as long as your aware of the differences on windows and unix, here are some of the common gotcha's
- Application.cfm - Application.cfm must have the exact case I'm using here.
- OnRequestEnd.cfm - Also must have the case I'm using here.
- CFINCLUDE Template Case - The template path in your CFINCLUDES is case sensitive on unix, you can use my coldfusion code review tool to find templates with incorrect case, as well as missing templates. It will also check the case on your Application.cfm and OnRequestEnd.cfm files in addition.
- Links, Images case sensitive - All paths to links, images, stylesheets, must be case sensitive as well, there is a workaround for this one however. If you install mod_speling in apache it will redirect the client to the proper page. This may not work all that well for images, stylesheets, or form posts however.
- CFEXECUTE - CFEXECUTE will still work on unix but the applications your executing may not.
- COM - not supported on unix.
So those are the main issues in porting a windows CF app to unix, the main thing to remember is case sensitivity.
- Writing Secure CFML cfObjective 2013 Slides
- Upgrading to Java 7 on Linux
- J2EE Sessions in CF10 Uses Secure Cookies
- Learn about ColdFusion Security at cfObjective 2013
- Session Loss and Session Fixation in ColdFusion
- FuseGuard 2.3 Released
- CKEditor Spell Checker Plugin
- Adobe Says Go Ahead and Upgrade your ColdFusion JVM