Document Sample
Coldfusion_MX_7_Server Powered By Docstoc
COVER STORY                     ColdFusion sollte hier stehen
                                Schlagwort MX 7 Server

A look at Macromedia’s new ColdFusion MX 7 Server for Linux

                                                                                            run-time variables that you can tweak to
                                                                                            improve overall performance. This fea-
                                                                                            ture gives you an easy-to-use interface to
                                                                                            manage settings that would require a
                                                                                            text file (php.ini) in PHP.
                                                                                               The Administrator also allows you to
                                                                                            manage data sources, web services,
                                                                                            scheduled tasks, tag extensions (more
                                                                                            on this later), sandbox security, and
                                                                                            more. With ColdFusion, you are discour-
                                                                                            aged from going near any configuration
                                                                                            files; the configuration options available
                                                                                            through the Administrator mean you’ll
                                                                                            probably never have to.

                                                                                            Rich Content
                                                                                            Macromedia is without a doubt the mas-
                                                                                            ter of rich content on the Internet. The
                                                                                            Flash format [3] for web-based anima-
                                                                                            tions, games, and user friendly interfaces
                                                                                            is almost the de facto standard. Java
                                                                                            Applets and ActiveX controls seem
                                                                                            clumsy in comparison.
                                                                                               It is no surprise, then, that Macrome-
                                                                                            dia have taken advantage of their own
Macromedia's new ColdFusion MX 7 Server creates highly available                            popular Flash technology to enhance the
                                                                                            content output options in ColdFusion.
and high performance web applications. We'll show you what is new                           Flash format is an option when render-
                                                                                            ing charts and input forms, and Macro-
and what is changed with the latest ColdFusion release.
                                                                                            media’s new FlashPaper [4] format
BY LARKIN CUNNINGHAM                                                                        (Figure 2) is an option when outputting
                                                                                            documents such as reports. Adobe’s PDF
                                                                                            (Portable Document Format) is also sup-
                                                                                            ported. The choice of PDF and FlashPa-

        he release of ColdFusion MX 7          Macromedia has continued to develop          per means you can output content that is
        [1] marks the tenth anniversary     ColdFusion and has added major                  guaranteed to be printable exactly as it
        of the ColdFusion web develop-      enhancements. This latest release has           appears in the web browser.
ment platform. Originally a C+ Win-         further added to ColdFusion’s arsenal of           Support for Flash and PDF on Linux
dows application, ColdFusion is now a       rich content generation with improved           has improved in recent months, meaning
J2EE-based development environment          charting capabilities, report generation        it should not be a major problem to
that runs on Linux, AIX, Mac OS X, and      using FlashPaper and PDF, and Flash-            deploy a ColdFusion intranet application
Solaris, as well as Windows.                based input forms, allowing for complex         on a Linux desktop environment while
   The ColdFusion platform was created      form layouts such as tabbing.                   offering all the rich content features you
and developed by Allaire Corporation.                                                       want.
Macromedia acquired ColdFusion in           The Administrator
2001 and released what would have been      ColdFusion comes with a web-based               The CFCHART Tag
ColdFusion version 6.0, calling the prod-   administrator application (Figure 1) to         ColdFusion’s CFCHART tag allows you to
uct ColdFusion MX to promote a connec-      help you manage your ColdFusion envi-           output smoothly rendered charts in
tion with other products in Macrome-        ronment. The admin application allows           PNG, JPEG, or Flash format. The Flash
dia's MX line, such as Dreamweaver and      you to adjust settings for client variable      format charts provide a number of addi-
Flash.                                      caching, Java / JVM memory, and other           tional charting options. such as lines or

38        ISSUE 56 JULY 2005                   W W W. L I N U X - M A G A Z I N E . C O M
                                                                  ColdFusion MX 7 Server
                                                             Schlagwort sollte hier stehen                           REVIEWS
                                                                                                                 COVER STORY

Figure 1: The ColdFusion Administrator keeps you away from the           Figure 2: An example of a FlashPaper document embedded in a web
command line and configuration files.                                    page.

bars rising from the x-axis to the correct     graphing, it has to be said, is more pol-       ters to configure your charts in Cold-
data point on the graph or pie charts fad-     ished, with anti-aliased smooth edges,          Fusion.
ing into view. Each chart format allows        and the native ColdFusion graphing sys-
for clickable area maps, which gives the       tem is easier to configure.                     Flash Forms, ActionScript,
user the power to assign URL values to           In Figure 3, you can see an example           and Remoting
chart segments. This feature gives you         chart showing levels of spam and                Flash-based input forms allow for client
the possibility of creating drill down         viruses in the past 30 days. In Listing 3,      side processing, validation, and form
charts for Management Information Sys-         you will find the CFCHART tags used to          rendering. Flash-based input forms
tems (MIS) or Decision Support Systems         create the chart depicted in Figure 3.          exceed the capabilities of standard
(DSS). ColdFusion offers many other              The CFCHARTSERIES tag is used to              HTML and JavaScript and are easier to
chart type options. For instance, you can      specify each line or bar in a line or bar       implement and deploy than Java Applet-
choose to include line, bar, pie, and scat-    chart and each segment in a pie chart. In       based input forms. Not only do Flash
ter charts.                                    the example described previously, we            forms give you more control over how
   PHP offers some third party options         loop through some queries, creating             data is entered to enforce business rules,
for creating graphs. Possibly the most         many data points with the CFCHART-              Flash also makes the user experience
popular graph option available with PHP        DATA tag. As you can see in Listing 3,          much richer. Figure 4 shows an example
is JpGraph, which offers a more compre-        you can use quite a number of parame-           of a Flash form that uses tabbing, a cal-
hensive array of chart types than Cold-
Fusion. JpGraph is available free for                                       The Tag-Based Approach
non-commercial use. ColdFusion’s
                                                CFML is a tag based language with your           between hashes (#) and included
                                                CFML and HTML store in .cfm web                  between CFML tags or as parameters to
   Listing 1: empquery.cfm                      pages. Rather than the traditional script-       a CFML tag are interpreted by ColdFu-
                                                ing approach used by PHP and ASP,                sion. Including the query as a parameter
 01 <CFQUERY NAME= qryGetREmps                  CFML uses tags similar to HTML, with             to the CFOUTPUT tag causes the tag con-
    DATASOURCE= #MyDSN# >                       opening and closing tags. Not all CFML           tents to be repeated for each row in the
 02          SELECT * FROM                      has to be tag based, however, because            query’s result set.
      employees                                 many tags have script equivalents. List-         Let's compare this with the PHP5 /
                                                ing 1 shows a simple SQL query fol-              mysqli [2] equivalent in Listing 2. Excep-
 03 </CFQUERY>
                                                lowed by the output of the query results.        tion catching code has been omitted for
                                                Notice how the CFML tags take parame-            simplicity.
 05 <CFOUTPUT QUERY= qryGetEmps >               ters like standard HTML. In the example          As you can see from the code snippets,
 06          Name: #qryGetEmps.                 above, the CFQUERY tag was used to               CFML can have the advantage of being
                                                populate a result set from the database          easier to write and easier to read than
      FirstName# #qryGetEmps.
                                                connection created using the MyDSN               equivalent PHP code. For a web designer
                                                connection string defined in the Cold-           with little or no background in program-
 07          Address: #qryGetEmps.              Fusion Administrator (more on this later).       ming, CFML is easier and quicker to
      Address1#, #qryGetEmps.                   Outputting the result set data is easily         learn than PHP. CFML lets a relative nov-
      Address2#                                 achieved using the CFOUTPUT tag. Vari-           ice create quite powerful code with just a
                                                ables and function calls enclosed                few tags.

                                                  W W W. L I N U X - M A G A Z I N E . C O M               ISSUE 56 JULY 2005           39
REVIEWS                           ColdFusion MX 7 Server

                                                                                               the case of CFML custom tags, you can
                                                                                               simply create a file containing your cus-
                                                                                               tom tag CFML code and place it in a
                                                                                               directory in ColdFusion’s custom tag
                                                                                               path (similar to a classpath). Java and
                                                                                               C++ custom tags (referred to as CFX
                                                                                               tags), however, must be explicitly
                                                                                               declared using the ColdFusion Adminis-
                                                                                               trator. Custom tags can then be used like
                                                                                               any other CFML tag, as if they were a
                                                                                               part of the core language. This is possi-
                                                                                               ble in PHP also, but it usually involves
                                                                                               either including other PHP source into
                                                                                               your page or recompiling PHP with a
                                                                                               new module.
                                                                                                  Because ColdFusion runs in a J2EE
                                                                                               application server, you also have access
                                                                                               to Java classes in the JVM’s classpath
                                                                                               and in the WEB-INF/lib and WEB-INF/
                                                                                               classes directories (as you would also
                                                                                               expect with Tomcat, for example). Using
                                                                                               the CFOBJECT tag, you can create
                                                                                               objects, allowing access to functions and
Figure 3: The CFCHART tags allow you to easily create stunning graphs                          methods. Access to JavaBeans is also
endar control, headings, and additional        This allows a separation of business               Interoperation between CFML, JSP,
layout features.                               logic from Flash presentation logic.            and Servlet pages is also possible. This
   ActionScript is the scripting language                                                      allows you to maintain legacy JSP /
used to interact with Flash MX. You can        Object-Oriented
use ActionScript in your ColdFusion            Programming                                         Database Abstraction
code to interact with a Flash Remoting         While both CFML and PHP are histori-
                                                                                                CFML includes, by default, a database
server to allow your ColdFusion applica-       cally structured programming languages,
                                                                                                abstraction layer that allows you to write
tion to interact with advanced Flash MX        both implement object-oriented features.         database-independent applications. The
applications and animations. A Flash           Neither can be called true object-ori-           CFQUERY tag, as an example, only
MX developer who doesn’t know CFML             ented languages, however, as they do             requires the DATASOURCE parameter
can still build a server-side ActionScript     not implement all of the features of true        to be able to connect to a database and
that interacts with ColdFusion resources.      object-oriented languages such as C++            perform a SQL query. Like ODBC, Cold-
                                               or Java. CFML provides what are called           Fusion offers a database abstraction
   Listing 2: empquery.php                     ColdFusion Components or CFCs. CFCs              layer. ColdFusion’s database abstraction
                                               support encapsulation, inheritance, and          layer can support ODBC connections
 01 $dbconn = new mysqli($dbhost,              introspection. CFCs are stored in .cfc           and native database connections using
    $dbuser, $dbpass, $dbname);                files rather than .cfm files.                    JDBC. Included are drivers for MySQL
                                                                                                (before 4.1), DB2, Informix, SQL Server,
 02                                               Listing 4 shows a sample CFC file that
                                                                                                Sybase, Oracle, and J2EE Datasources
 03 $result =                                  defines a component called Convert-
                                                                                                (using JNDI). Oracle and Sybase drivers
    $dbconn->query('SELECT * FROM              Temp, which converts from Celcius to             are only included with the Enterprise
    employees');                               Fahrenheit and vice versa. Listing 5             edition of ColdFusion, however, you can
                                               shows some sample CFML code that                 create data sources using your own
                                               invokes the methods in the component.            JDBC drivers (typically by copying a
 05 while ($row = $result->fetch_
                                                  ColdFusion’s object-oriented features         JAR file to an appropriate library direc-
                                               are not quite as elegant as PHP 5’s              tory) and specifying the JDBC url and
 06 {                                          implementation of object-oriented func-          class name for your driver. You can
 07          printf( Name: %s                  tionality, but ColdFusion gives you what         achieve something similar using a JNDI
                                               you need to create easily maintainable           resource.
      %s<br> , $row['FirstName'],
      $row['LastName']);                       component-based applications.                    There are ways of incorporating data-
                                                                                                base abstraction into PHP using ADODB
 08          printf( Address: %s,
      %s , $row['Address1'],
                                               Extending ColdFusion                             and Pear DB, however, these techniques
                                               You can extend the functionality of Cold-        require the installation of additional files
      $row['Address2']);                                                                        and can require you to include addi-
                                               Fusion through the use of Custom Tags
 09 }                                                                                           tional files into your PHP scripts.
                                               written using CFML, Java, or C++. In

40        ISSUE 56 JULY 2005                      W W W. L I N U X - M A G A Z I N E . C O M
                                                                     ColdFusion MX 7 Server                             REVIEWS

                                              ColdFusion server and can be accessed           obeying the instructions provided in
                                              by multiple ColdFusion instances (by            robots.txt and following links specified
                                              installing ColdFusion in multiserver            in HTML HREF, FRAME, and META
                                              mode – more on this below). Using the           Refresh / Redirect tags. The capabilities
                                              ColdFusion Administrator, you can cre-          provided by the Verity Spider allow you
                                              ate a Collection. A Collection is a store       to create an intelligent search facility on
                                              on disk for Verity searchable content.          your website.
                                                A number of CFML tags are available
                                              to index content (for example Plain text,       Editions
                                              PDF document, and HTML documents)               ColdFusion comes in three different edi-
                                              and to search the content. You can also         tions. The Developer edition can be
                                              index content returned from a query.            accessed from the local machine running
                                              This feature of ColdFusion allows you to        ColdFusion and two remote clients. This
                                              quickly search through large amounts of         makes it possible for a small team of
Figure 4: Flash Forms give you greater        text much faster than using a SQL               developers to work on application devel-
control over how users input their data.      SELECT query, where large text fields           opment using the same ColdFusion
                                              (for example the TEXT datatype in               instance. The Developer edition contains
Servlet applications while converting to      MySQL) cannot be indexed. One area              all of the functionality in ColdFusion and
CFML. You can incorporate CFML func-          this technology can be deployed in is a         is free to download.
tionality into your existing JSP applica-     knowledge base.                                    The Standard edition contains just
tions, for example, to take advantage of        New in ColdFusion MX 7 is the Verity          about all of the functionality of ColdFu-
ColdFusion’s charting or business report-     Spider. The Verity Spider allows you to         sion, except for some features concerned
ing features. Conversely, if there are cer-   index whole directories or websites             primarily with performance and avail-
tain operations best performed by a JSP       dynamically. Unlike the CFINDEX CFML            ability. Rather than explaining the fea-
or a Servlet page, you can incorporate        tag, which allows you create specific           tures that the professional edition con-
that functionality into CFML applica-         indexes for searching, the Verity Spider        tains, it is easier to talk about the fea-
tions.                                        creates the searchable content dynami-          tures only available in the third and final
                                              cally. The Verity Spider supports a wide        edition of ColdFusion, the Enterprise
Search Engine                                 range of document types, including              edition. The retail price for Standard Edi-
ColdFusion comes with a powerful              HTML, PDF, Microsoft Office, Word-              tion is US$ 1,299 / EUR 1,299. For a bit
search engine called Verity. The Verity       Perfect, XML, and others. Verity Spider         more money (Enterprise Edition costs
engine can run independently of the           behaves just like other website spiders,        US$ 5,999 / EUR 5,999), you get addi-

                               Listing 3: chart.cfm                                            Listing 4: convertTemp.cfc
 01 <cfchart scalefrom="0"                          item="#DateFormat(scan_                    01 <cfcomponent>
    scaleto="1" showlegend="yes"                    date,"dd-mmm-yy")#
                                                                                               02      <!--- Celsius to Fahrenheit
    markersize="4"                                  value="#(pspam_sum + bspam_
                                                                                                    conversion method. --->
    labelformat="percent"                           sum) / total_sum#">
                                                                                               03      <cffunction name="ctof"
 02 title="Percentage Spam and                 08           </cfloop>
    Viruses - Last 30 days" backgr             09 </cfchartseries>
    oundcolor="##eeeeee"                                                                       04        <cfargument name="temp"
                                               10 <cfchartseries type="line"                        required="yes" type="numeric">
    format="FLASH"                                                                             05        <cfreturn
    xAxisTitle="Date"                                                                               ((temp*9)/5)+32>
 03 yAxisTitle="Percentage of                                                                  06     </cffunction>
                                               11          <cfloop
    Overall" chartHeight="400"                                                                 07
    chartWidth="540" show3D="no"
                                               12                 <cfchartdata                 08      <!--- Fahrenheit to Celsius
    showXGridlines="yes" seriesPla
                                                    item="#DateFormat(scan_                         conversion method. --->
                                                    date,"dd-mmm-yy")#"                        09      <cffunction name="ftoc"
                                                    value="#virus_sum / total_                      output="false">
 05 <cfchartseries type="line"                      sum#">
                                                                                               10        <cfargument name="temp"
                                               13           </cfloop>                               required="yes" type="numeric">
    markerstyle="circle">                      14 </cfchartseries>                             11        <cfreturn
                                               15                                                   ((temp-32)*5/9)>
 06          <cfloop
      query="qry30days">                       16 </cfchart>                                   12     </cffunction>

 07                    <cfchartdata                                                            13 </cfcomponent>

                                                 W W W. L I N U X - M A G A Z I N E . C O M              ISSUE 56 JULY 2005          41
REVIEWS                           ColdFusion MX 7 Server

tional enterprise level features. The next       You can create custom event gateways         other scripting language. And what
section describes the Enterprise edition.     to interact with mobile devices and             ColdFusion cannot do, you can do by
                                              instant messaging servers, for example,         extending ColdFusion with Java, JSP, or
Enterprise Edition Features                   or any other server application via any         Servlets.
The Enterprise Manager allows you to          networking protocol (using Java sock-             The choice of whether you use Cold-
manage multiple instances of ColdFu-          ets). You can also use the included gate-       Fusion will depend on the nature of the
sion on a single server. The configura-       ways to SMS, XMPP (Extensible Messag-           application. For rich content sites using
tion is similar to other J2EE application     ing and Presence Protocol), Sun’s JMS           charts, Flash forms, FlashPaper or PDF,
servers like Tomcat, where an applica-        (Java Messaging Service) and Lotus              ColdFusion is a good choice. For general
tion server binary base is shared among       Sametime. XMPP [6] is an open source            purpose content management systems,
multiple private JVMs (Java Virtual           instant messaging solution and protocol         ColdFusion is also an excellent choice.
Machines). This means that multiple           from the Jabber [7] Software Founda-            For rapid development, ColdFusion
applications can enjoy isolation from         tion. Lotus Sametime [8] is a product           offers an easy-to-learn, tag-based script-
each other, providing better security and     offered by IBM for instant messaging            ing language that allows you to create
stability without the requirement of sep-     and web conferencing.                           powerful applications with the minimum
arate dedicated servers. You can also            The Enterprise edition also lets you         of coding effort. For many, this is enough
cluster these applications to improve         take advantage of a high performance,           to justify even the price of the Enterprise
performance and availability.                 multithreaded business reporting engine.        edition of ColdFusion, which allows you
   JRun [5] is included with the Enter-       This is ideal for Management Informa-           to construct the kind of highly available
prise edition, giving you a commercial        tion Systems, which can also use the            and high-performing environment that
alternative to Tomcat. You can combine        charting features to create drill down          mission critical applications demand.
your ColdFusion application code with         statistics.                                       For many developers on the Linux
JSP or Servlet code in JRun.                     You can deploy your applications as          platform, it will come down to a choice
   You can deploy your ColdFusion appli-      Java bytecode, avoiding the exposure of         of PHP, JSP / Servlets, or ColdFusion.
cations using your preferred J2EE appli-      your source code. This is important if          ColdFusion is the only choice requiring
cation server. JRun, Weblogic, and Web-       you want to protect your intellectual           the purchase of a license for deployment
sphere are supported by Macromedia.           property.                                       in a production environment, though all
   Security is enhanced for virtual host-                                                     are free to download and develop on.
ing environments using sandbox secu-          Supported Platforms                             And with an ever growing number of
rity. Sandbox security allows you to set      ColdFusion is supported on a number of          hosting companies offering support for
security policies, such as tag, function,     platforms, including Linux, Windows,            ColdFusion at reasonable prices, you
datasource, and IP address restrictions,      Solaris, AIX, and Mac OS X (develop-            may never need to pay for a license.
on directories. Applications running          ment only). Red Hat Enterprise Linux            In short, if you’re thinking about explor-
within the directories have no access to      2.1 and 3.0, SUSE Linux Enterprise              ing the benefits of a commercial product,
the settings or files of any other applica-   Server 8, and TurboLinux 8 (Japanese            before you commit to anything else,
tions.                                        only) are supported by Macromedia,              you should at least investigate Cold-
                                              though there should be no issues run-           Fusion MX 7. ■
          Listing 5:                          ning on CentOS 3, White Box Linux 3,
      convTempForm.cfm                        and many other Linux distributions. In                           INFO
                                              theory, it should be possible to deploy
 01 <cfinvoke                                                                                  [1] Macromedia ColdFusion MX 7:
                                              ColdFusion on any Java platform. JRun,     
                                              BEA Weblogic, and IBM Websphere are                  software/coldfusion/
                                              supported by Macromedia, but instruc-
 02                                                                                            [2] PHP 5 and the mysqli module:
                                              tions are provided for Tomcat, and there   
                                              should be few issues deploying on JBoss              mysqli.php
                                              or Resin.
                                                                                               [3] Macromedia Flash: http://www.
 03 <cfoutput>30 degrees Celsius                 ColdFusion can run either as a stand-   
    is #newtemp# degrees                      alone web server or in conjunction with
                                                                                               [4] Macromedia FlashPaper:
    Farenheit.</cfoutput>                     Apache (1.3.27 or higher, 2.0.43 or        
 04 <cfinvoke                                 higher), iPlanet 6.x, or Sun ONE 6.x.                software/flashpaper/
                                                                                               [5] Macromedia JRun: http://www.
    method="ftoc"                             Is ColdFusion For You?                     
 05                                           There is no simple answer to the ques-
                                                                                               [6] XMPP Protocol:
      returnvariable="newtemp"                tion of why or when you might benefit
                                                                                               [7] Jabber Software Foundation:
      temp=64>                                from using ColdFusion. For some appli-
                                              cations, PHP or Perl or JSP will be the
 06 <cfoutput>64 degrees                                                                       [8] Lotus Sametime:
                                              better choice, and for others, ColdFusion
    Fahrenheit is #newtemp#                                                              
                                              is best. There is little you cannot do with
    degrees Celsius.</cfoutput>                                                                    product3.nsf/wdocs/homepage/
                                              ColdFusion that you can do with any

42        ISSUE 56 JULY 2005                     W W W. L I N U X - M A G A Z I N E . C O M

Shared By: