Transcript COLD FUSION

COLD FUSION
Deepak Sethi
What is it….
Cold fusion is a complete web application server mainly
used for developing e-business applications. It allows
programmers to develop applications that access
databases.
Its also a language to write on an application which run on
the server. It provides simple scripting syntax for
usage on high end servers. It was produced in 1995
by Macromedia/ Allaire.
Its also a tool for rapid development as it’s a tag based
programming language also visual tools make it highly
productive.
When the page is loaded cold fusion tags are executed. If there are any calls to
the database , Cold fusion accesses the database and performs the actions
(inserting data , updating , retrieving data).
The browser then displays the running HTML code as it does with any other
HTML code.
Performance….

High Performance- integrating with databases, emails,
directories, J2EE, .NET, XML, and enterprise systems lets
one develop complex Web applications quickly and easily.

Security – Cold Fusion also benefits from the latest
internet security tools. It provides web based and network
security to provide enterprises with secure systems.
Performance….

Saves maintenance money: It hides complexity and
uses less lines of code (more intuitive) to achieve more results.
It allows its users to migrate their material to various
web servers & database engines with minimal amount
of changes.

Applications can change platforms and Database
engines: if an organization decides to upgrade their operating
system , they can readily move their cold fusion applications
from web servers and operating systems with minimal
changes.Database engines can be changed with a little effort.
Advantages
Cold Fusion has several advantages. A lot of companies
are switching to it even when PHP and ASP are
available free of cost. There are several features
which are included in it :
1.
File uploading feature with ease
2.
Full text search
3.
Reading and writing mails in a much easier way then
ASP.
4.
Business graphing
Other advantages



Integration of HTML and XML , making web based
applications more easier and faster to develop.
Enabling encapsulation , hence eliminating excessive
scripting and increasing productivity.
Cold Fusion Extensions (CFX) that serve as re-usable
components.
Drawbacks…
-Only runs on windows environment (windows NT)
- Fairly expensive
Cold Fusion vs. ASP
Database connectivity
ASP: connectivity through ODBC / ADO objects
Cold Fusion: connectivity through CF tags
*** Cold fusion tags for connectivity are some what easier then ADO objects
Debugging
ASP: Runtime errors sent to browser
Cold Fusion: configurable debugging information sent to browser.
*** Cold fusion has a better debugging
Cold Fusion vs. ASP
Syntax
ASP: developer friendly, scripting syntax, Visual Basic friendly
Cold Fusion: Tag based , HTML friendly. Supports Java script
scripting.
*** Cold fusion tags are relatively simpler
Data Manipulation
ASP: pretty much direct
Cold Fusion: tags usage makes it implicit
*** ASP record set manipulation instead of tags is more flexible
Cold Fusion vs. ASP
Extendibility
ASP: server components are created using tools like VB ,VC++
Cold Fusion: Extension tags can be created by using CF language ,
C++ API. Java class usage can also be added using outside tags.
*** CF can use any ASP components plus a user can define his/her tags.
Pre-built functionality
ASP: uses VB library functions
Cold Fusion: function library and server objects
*** both have excellent support
Cold Fusion vs. ASP
Error Handling
ASP: Default screens are ugly . One can trap and handle errors in the
script but the process is ugly.
Cold Fusion:Specified default errors in HTML templates, consistent
display , ability to trap errors in script and conditional logics
*** Cold Fusion better support for customized messages
CFML
CFML stands for Cold Fusion Markup language. This
programming language is tag based and is mainly used
for developing web based applications. Its supported by
Cold Fusion and some other third party servers.
It has mainly 100 tags and almost 200 different functions to
perform various programming operations. Each CFML
tag has an opening and a closing tag just like HTML.
CFML files are given the extension .cfm just like HTML files
are given .html extension.
Getting started…..
One mainly requires two things to work with Cold Fusion:
1.
Cold fusion server to run ones applications
2.
An editing environment . Best is Dream weaver MX
but any other text editor could be used as well.
One also needs to have a good knowledge of HTML and
SQL for working with Cold Fusion.
Cold Fusion can be directly brought from Macromedia:
www. macromedia.com/buy/
Getting started….
A trial version can also be downloaded from
macromedia’s website:
www.macromedia.com/software/coldfusion
This would run free of charge for 30 days from the day of
installation.
 All major databases are supported by Cold Fusion :

Microsoft SQL Server, Oracle, DB2, Sybase, and Informix
Syntax…
Forms
<FORM ACTION="template name" METHOD="POST">
Form fields, CFML and HTML tags
</FORM>
Required fields
<input type=“text” name=“name” size=“10”>
<input type=“hidden” name=“name_Required” value=“Name is required”>
Gives an error message
Syntax
Queries
<CFQUERY>
<CFQUERY name=“userinfo” DATASOURCE=“database name”>
Select user_id, user_name
From users
Where user_name=“MSU”
</CFQUERY>
<CFOUTPUT>
<CFOUTPUT>#user_name#</CFOUTPUT>
This will display the user name MSU on the page
Syntax
Displaying values from a query to a select:
<h5>Please select a user</h5>
<select name=“user_id">
<cfoutput query =“userinfo">
<option value="#userinfo.user_id#"># userinfo.user_name#</option>
</cfoutput>
</select>
This will display user name from the query in the single select
Syntax
UPDATE from form fields
<CFQUERY NAME=“user update“ DATASOURCE=“database name">
UPDATE users (user_name)
VALUES ( ‘#Form.name#')
</CFQUERY>
Syntax
sending e-mails
<CFMAIL>
<cfmail [email protected]
from=“[email protected]"
bcc=“[email protected]"
subject=“announcements">
Syntax
File Upload
<cffile action = "upload"
fileField = "formfield"
destination = "full_path_name"
nameConflict = "behavior"
accept = "mime_type/file_type"
mode = "permission”>
File actions: rename, copy, delete, move
Syntax
Cookie
<cfcookie name="cookie_name"
value="text"
expires="period" path "url">
<cfcookie name = “user" value = "#Form.user_name#" expires = "10">
Syntax
Conditional logics
<cfoutput query = “users">
<cfif user_name is “MSU" OR user_name is “Moorehead">
<H4>user:<cfif user is “MSU">MSU<cfelse>Moorehead
</cfif>
</H4>
<cfelse>”user not found”
</cfif>
</cfoutput>
QUESTIONS???