ColdFusion Markup Language

Last updated
Cold Fusion Markup Language (CFML)
Paradigm imperative, object-oriented
Designed by Jeremy Allaire, Joseph J. Allaire
Developer Adobe Systems (ColdFusion), Lucee Association (Lucee), New Atlanta and aw2.0 (openBD), The Railo Company (Railo)
First appeared1995;28 years ago (1995)
Stable release
2023 Release / 2023;0 years ago (2023)
Implementation language Java
OS Cross-platform
License Depends on the implementation. Proprietary, LGPL, and GPL-licensed engines are all available.
Filename extensions .cfm, .cfc
Website www.adobe.com/products/coldfusion
Major implementations
Adobe ColdFusion, Lucee, Railo, BlueDragon, Open BlueDragon
Influenced
Lucee

ColdFusion Markup Language, more commonly known as CFML, is a scripting language for web development that runs on the Java virtual machine (JVM), the .NET framework, and Google App Engine. Several commercial and free and open-source software implementations of CFML engines are available, including Adobe ColdFusion, Lucee, New Atlanta BlueDragon (Java and .NET versions), Railo, Open BlueDragon, and other CFML server engines.

Contents

Synopsis

In its simplest form, like many other web scripting languages, CFML augments standard HTML files with database commands, conditional operators, high-level formatting functions, and other elements to produce web applications. [1] [2] CFML also includes many other constructs including ColdFusion Components (CFCs), CFML's version of objects, that allow separating business logic from presentation.

CFML can be written using either tags or CFScript, which resembles JavaScript (ECMAScript).

The pages in a CFML application include the server-side CFML tags and functions in addition to HTML tags. Modern CFML applications also tend to have CFCs that are accessed by the CFML pages for executing business logic. When a web browser requests a page in a ColdFusion application, it is automatically pre-processed by the ColdFusion application server. [3]

CFML can also be used to generate other languages, aside from HTML, such as XML, JavaScript, CSS, and so on.

Despite the name, CFML is not a markup language. It is also not SGML, since certain core CFML features prevent it from complying.

The CFML engine is configured in such a way that certain file extensions on the server (.cfm, .cfc) are handed off to the CFML engine for processing. In the case of the Java-based engines this is accomplished via Java servlets. The CFML engine only processes CFML tags and functions; it returns text outside of CFML tags and functions to the web server unchanged. [4]

History

Named Cold Fusion at the outset, the software was created in 1995 by the Allaire Corporation, originally located in Minnesota. It later moved to Cambridge, Massachusetts and then finally to Newton, Massachusetts before being acquired by Macromedia in 2001. Allaire Cold Fusion thus became Macromedia Cold Fusion. At the release of version 4, the space in the name was removed to become ColdFusion. Adobe acquired Macromedia in 2005. As of 2023, it is still actively developing ColdFusion.

In 1998 Alan Williamson and his Scottish company, "n-ary", began creating a templating engine for Java to simplify common programming tasks. [5] Williamson was using curly-brace notation instead of tags, but when he saw an example of CFML and how it was solving similar problems (although not in Java) using a tag syntax, he started developing what would eventually become BlueDragon, which was the first Java implementation of the CFML language. (ColdFusion was written in C and C++ until version 6.0, the first Java-based version, was released in 2002.) New Atlanta licensed BlueDragon around 2001 and made it available as a commercial product, eventually creating a .NET implementation of CFML. Open BlueDragon is a fork of the commercial BlueDragon product and was first released in 2008.

The Railo CFML engine began as a student project in 2002 and was first launched as a commercial project in 2005. [6] Railo announced they were making the engine open source in 2008, and the first open source version was released in 2009.

On June 18, 2009, Adobe announced at the CFUnited conference that it had formed a CFML Advisory Committee [7] that would be responsible for guiding and reviewing changes to the CFML language. This effort was disbanded in 2010. The Google Group CFML Conventional Wisdom was created as a forum for open, public discussions about language and engine features; its use has dwindled since 2011.[ citation needed ]

In 2012, the OpenCFML Foundation was launched. Its function is to push open-source CFML applications and platforms.

Former Railo lead developer Michael Offner launched Lucee, a fork of Railo, in London on January 29, 2015. Backed by community supporters and members of the Lucee Association, the goal of the project is to provide the functionality of CFML using fewer resources, giving better performance and to move CFML past its roots and into a modern and dynamic Web programming platform.

Syntax

CFML tags have a similar format to HTML tags. They are enclosed in angle brackets (< and >) and generally have zero or more named attributes, though some tags (e.g. cfset, cfif) contain an expression rather than attributes. Many CFML tags have bodies; that is, they have beginning and end tags with text to be processed between them. For example:

<cfoutput>#value# Bob! </cfoutput>

Other tags, such as cfset and cfftp, never have bodies; all the required information goes between the beginning (<) character and the ending (>) character in the form of tag attributes (name/value pairs), as in the example below. If it is legal for tags not to have a body, it is syntactically acceptable to leave them unclosed as in the first example, though many CFML developers choose to self-close tags as in the second example to (arguably) make the code more legible.

<cfsetvalue="Hello"><cfsetvalue="Hello"/>

Even if the tag can have a body, including a body may not be necessary in some instances because the attributes specify all the required information. In these cases, as with the second example above, the end tag (and hence, the tag body) may be omitted and the tag may be self-closing as in the following example: [8]

<cfexecutename="C:\\winNT\\System32\\netstat.exe"arguments="-e"outputfile="C:\\Temp\\out.txt"timeout="1"/>

Various tags offer the ability to type-check input parameters (e.g. cffunction, cfparam, cfqueryparam) if the programmer declares their type specifically. This functionality is used with cfqueryparam to secure web applications and databases from hackers and malicious web requests such as SQL injection.

Built-in tags

Nearly 100 tags and many more functions make up the heart of the CFML language. The following lists CFML tags by their function or purpose. [9]

Custom tags

CFML allows language extensions in the form of custom tags, which are tags created by the developer that are not part of the CFML language itself. Custom tags are regular CFML files which are intended to be invoked as tags, although it is possible to treat a template as both a custom tag and a regular template. Custom tags are written in CFML and are typically invoked by prefixing the custom tag's file name with cf_, although there are other ways to invoke custom tags.

If a template is invoked as a custom tag, the attributes used to invoke that tag are available within the tag in an attributes scope and the variables for the calling page are accessible via the caller scope.

For example, if writing a custom tag to perform addition, taking two attributes and adding them together, the tag would be an addition.cfm file which could look like this:

<cfsetcaller.addition=attributes.first+attributes.second/><cfexitmethod="exitTag"/>

Assuming the tag is in the same directory as the file (or in a pre-defined customtags directory), it can be invoked thus:

<cf_additionfirst="1"second="2">

CFX tags are custom tags which are developed using Java or C++, and are prefixed with cfx_ just like cf_. Java and C++ tags are added to the CFML runtime environment using the CFML engine's administrator or by editing configuration files.

On some CFML engines JSP tags can also be included in CFML pages using the <cfimport> tag.[ citation needed ]

Functions

ColdFusion Markup Language includes a set of functions that you use to perform logical and arithmetic operations and manipulate data.

functionreferencecode
Array [10] (ArraySort, ArrayAppend, ArrayDeleteAt...)
Conversion [11] (URLEncodedFormat, ToString...)
Date and time [12] (LsTimeFormat, DateAdd, DateDiff...)
Decision [13] (IsDefined, IIF...)
Display and formatting [14] (CJustify, NumberFormat...)
Dynamic evaluation [15] (DE, Evaluate...)
Extensibility [16] (CreateObject, ToScript...)
Image [17] (ImageRotate, ImageAddBorder...)
International functions [18] (SetLocale, GetTimeZoneInfo...)
List [19] (FindOneOf, ListSetAt...)
Mathematical [20] (Randomize, Sqr...)
Other functions [21] (WriteOutput, GetBaseTemplatePath...)
Query [22] (QueryAddColumn, QuerySetCell...)
Security [23] (Encrypt, Decrypt...)
String [24] (Reverse, HTMLCodeFormat...)
Structure [25] (StructKeyExists, StructDelete...)
System [26] (GetTickCount, GetTempFile...)
XML [27] (XMLParse, GetSOAPResponse...)

ColdFusion Components (CFCs)

CFCs provide some (not all) of the typical features and functionality that are provided by object-oriented (OOP) languages. To create a CFC:

Create a file with a .CFC extension (this distinguishes CFCs from ColdFusion templates, which have a .CFM extension).
Use four tags to create the components, define their functions and arguments, and return a value.
<cfcomponent>: Defines a CFC
<cffunction>: Defines the functions (methods) within a CFC
<cfargument>: Defines the arguments (parameters) that a function accepts
<cfreturn>: Returns a value or result from a function

CFCs are plain CFML. Within a CFC any CFML tag, function, custom tag, other components, etc. may be used.

CFCs can be used in various ways. If a method contained in a CFC simply needs to be invoked, the <cfinvoke> tag will create an instance of the CFC, invoke the desired method, and then destroy the instance of the CFC. <cfinvoke> takes the name of the component (minus the .cfc extension) and the method to execute. To access any returned data, the RETURNVARIABLE attribute provides the name of a variable to contain whatever the function returns. CFCs are created using four tags, saved as .CFC files, and invoked using the <cfinvoke> tag. [28]

In the example below, component temperature.cfc has a method FtoC which converts temperature from Fahrenheit to Celsius. The test.cfm template invokes the method and converts 212 degrees Fahrenheit and outputs the result.

<!--- temperature.cfc ---><cfcomponent><cffunctionname="FtoC"access="public"returntype="numeric"><cfargumentname="fahrenheit"required="yes"type="numeric"/><cfsetanswer=(fahrenheit-32)*100/180/><cfreturnanswer/></cffunction></cfcomponent><!--- test.cfm ---><cfsetfDegrees=212/><cfinvokecomponent="temperature"method="FtoC"returnvariable="result"><cfinvokeargumentname="fahrenheit"value="#fDegrees#"/></cfinvoke><cfoutput>#fDegrees#&deg;F = #result#&deg;C</cfoutput><br/>

CFCs may also be instantiated as objects. Assuming a CFC file called Person.cfc, an instance of this CFC would be instantiated as follows:

<cfsetperson=CreateObject("component","Person")/>

CFCs also form the basis of the ability to create web services in CFML. A CFC is created in the usual way, and the attribute access="remote" added to any function within the CFC will make that function available to be called as a SOAP-based web service. The CFML engine auto-generates a WSDL and creates all the necessary stubs for the web service to function.

Related Research Articles

<span class="mw-page-title-main">JavaScript</span> High-level programming language

JavaScript, often abbreviated as JS, is a programming language that is one of the core technologies of the World Wide Web, alongside HTML and CSS. As of 2023, 98.7% of websites use JavaScript on the client side for webpage behavior, often incorporating third-party libraries. All major web browsers have a dedicated JavaScript engine to execute the code on users' devices.

Jakarta Server Pages is a collection of technologies that helps software developers create dynamically generated web pages based on HTML, XML, SOAP, or other document types. Released in 1999 by Sun Microsystems, JSP is similar to PHP and ASP, but uses the Java programming language.

<span class="mw-page-title-main">Adobe Dreamweaver</span> Proprietary web development software

Adobe Dreamweaver is a proprietary web development tool from Adobe Inc. It was created by Macromedia in 1997 and developed by them until Macromedia was acquired by Adobe Systems in 2005.

<span class="mw-page-title-main">Adobe ColdFusion</span> Rapid Web app development platform

Adobe ColdFusion is a commercial rapid web-application development computing platform created by J. J. Allaire in 1995. ColdFusion was originally designed to make it easier to connect simple HTML pages to a database. By version 2 (1996) it had become a full platform that included an IDE in addition to a full scripting language.

HomeSite was an HTML editor originally developed by Nick Bradbury. Unlike WYSIWYG HTML editors such as FrontPage and Dreamweaver, HomeSite was designed for direct editing, or "hand coding", of HTML and other website languages.

BlueDragon is a ColdFusion Markup Language (CFML) engine comparable to Adobe Systems's ColdFusion. It is licensed and distributed by New Atlanta from TagServlet Ltd based in Scotland. BlueDragon is also distributed and supported by BEA Systems on their Oracle WebLogic Server server platform.

Railo Server, commonly referred to as Railo, is open source software which implements the general-purpose CFML server-side scripting language, often used to create dynamic websites, web applications and intranet systems. CFML is a dynamic language supporting multiple programming paradigms and runs on the Java virtual machine (JVM).

IgniteFusion is a freeware CFML script engine that runs cfm script files. Similar to Perl or PHP script engines the IgniteFusion script engine runs as an executable on the server. Other CFML engines include Adobe ColdFusion, New Atlanta BlueDragon, Railo, Lucee, and Coral Web Builder.

Allaire Corporation was a computer software company founded by Jeremy and JJ Allaire in Minnesota, later headquartered in Cambridge, then Newton, Massachusetts. It commenced operations in May 1995, had its initial public offering on NASDAQ in January 1999, and was acquired by rival Macromedia in early 2001.

CFScript is an extension of CFML on the ColdFusion platform. CFScript resembles JavaScript. Some ColdFusion developers prefer it since it has less visual and typographical overhead than ordinary CFML.

SmithProject was an Open Source CFML script engine.

<span class="mw-page-title-main">Scripting language</span> Programming language for run-time events

A scripting language or script language is a programming language that is used to manipulate, customize, and automate the facilities of an existing system. Scripting languages are usually interpreted at runtime rather than compiled.

FusionDebug an interactive step debugger for CFML, compatible with Adobe ColdFusion, Railo and Lucee. It enables developers to step through code line-by-line, step into, over or out of code to better understand how code is running.

<span class="mw-page-title-main">ColdBox Platform</span> Web application framework

ColdBox is a free, open-source, conventions-based, modular web application framework intended for building enterprise applications with ColdFusion (CFML) using a Hierarchical MVC approach.

<span class="mw-page-title-main">Adobe ColdFusion Builder</span>

Adobe ColdFusion Builder is the name for Adobe's Eclipse-based development IDE that can be used to build applications for ColdFusion. The product's original codename, "Bolt", is a reference to the original lightning icon for ColdFusion from the Allaire days. In 2010, Adobe released the product and officially renamed it Adobe ColdFusion Builder, often referred to as CFBuilder.

<span class="mw-page-title-main">OpenFL</span>

OpenFL is a free and open-source software framework and platform for the creation of multi-platform applications and video games. OpenFL applications can be written in Haxe, JavaScript, or TypeScript, and may be published as standalone applications for several targets including iOS, Android, HTML5, Windows, macOS, Linux, WebAssembly, Flash, AIR, PlayStation 4, PlayStation 3, PlayStation Vita, Xbox One, Wii U, TiVo, Raspberry Pi, and Node.js.

Lucee is an open source implementation of a lightweight dynamically-typed scripting language for the Java virtual machine (JVM). The language is used for rapid development of web applications that compile directly to Java bytecode, and is compatible with contemporary CFML script and tag language variants, and provides configurable support for legacy CFML.

<span class="mw-page-title-main">ContentBox Modular CMS</span> Content management system

ContentBox Modular CMS is an open-source content management system for CFML, created by Ortus Solutions, Corp. ContentBox has been designed as a modular HMVC software based on Hibernate ORM and the ColdBox Platform.

References

  1. Adobe ColdFusion 8 – About Internet applications and web application servers Archived 2012-05-13 at the Wayback Machine . Livedocs.adobe.com. Retrieved on 2013-09-17.
  2. Open BlueDragon Manual. Openbd.org. Retrieved on 2013-09-17.
  3. Smith, Michael What is ColdFusion? fusionauthority.com
  4. Tags Archived March 24, 2008, at the Wayback Machine
  5. Open BlueDragon Steering Committee Interview Series – Alan Williamson. alan.blog-city.com
  6. About Railo Archived 2011-06-30 at the Wayback Machine . Getrailo.org. Retrieved on 2013-09-17.
  7. http://corfield.org/entry/CFML_Advisory_Committee Archived 2009-01-07 at the Wayback Machine CFML Advisory Committee – An Architect's View. Corfield.org. Retrieved on 2013-07-21.
  8. Tag syntax Archived May 27, 2008, at the Wayback Machine
  9. Tags by function Archived 2008-05-09 at the Wayback Machine . (PDF) Retrieved on 2013-09-17.
  10. Array functions Archived 2008-12-10 at the Wayback Machine . Livedocs.adobe.com. Retrieved on 2013-09-17.
  11. Conversion functions Archived 2008-12-08 at the Wayback Machine . Livedocs.adobe.com. Retrieved on 2013-09-17.
  12. Date and time functions Archived 2008-12-02 at the Wayback Machine . Livedocs.adobe.com. Retrieved on 2013-09-17.
  13. Decision functions Archived 2009-02-01 at the Wayback Machine . Livedocs.adobe.com. Retrieved on 2013-09-17.
  14. Display and formatting functions Archived 2008-12-20 at the Wayback Machine . Livedocs.adobe.com. Retrieved on 2013-09-17.
  15. Dynamic evaluation functions Archived 2008-12-07 at the Wayback Machine . Livedocs.adobe.com. Retrieved on 2013-09-17.
  16. Extensibility Archived 2009-02-14 at the Wayback Machine . Livedocs.adobe.com. Retrieved on 2013-09-17.
  17. Image functions Archived 2009-01-31 at the Wayback Machine . Livedocs.adobe.com. Retrieved on 2013-09-17.
  18. International functions Archived 2009-02-08 at the Wayback Machine . Livedocs.adobe.com. Retrieved on 2013-09-17.
  19. List functions Archived 2008-12-10 at the Wayback Machine . Livedocs.adobe.com. Retrieved on 2013-09-17.
  20. Mathematical functions Archived 2008-12-07 at the Wayback Machine . Livedocs.adobe.com. Retrieved on 2013-09-17.
  21. Other functions Archived 2009-01-30 at the Wayback Machine . Livedocs.adobe.com. Retrieved on 2013-09-17.
  22. Query functions Archived 2009-02-21 at the Wayback Machine . Livedocs.adobe.com. Retrieved on 2013-09-17.
  23. Security functions Archived 2008-12-05 at the Wayback Machine . Livedocs.adobe.com. Retrieved on 2013-09-17.
  24. String functions Archived 2009-01-29 at the Wayback Machine . Livedocs.adobe.com. Retrieved on 2013-09-17.
  25. Structure functions Archived 2009-02-14 at the Wayback Machine . Livedocs.adobe.com. Retrieved on 2013-09-17.
  26. System functions Archived 2009-02-01 at the Wayback Machine . Livedocs.adobe.com. Retrieved on 2013-09-17.
  27. XML functions Archived 2009-02-20 at the Wayback Machine . Livedocs.adobe.com. Retrieved on 2013-09-17.
  28. Forta, Ben Using ColdFusion components. adobe.com