Deploying CFML on J2EE Servers - PowerPoint PPT Presentation

About This Presentation
Title:

Deploying CFML on J2EE Servers

Description:

Using the BlueDragon WAR Deployment Wizard ... pages, classes, and other resources that make up a complete application on a web ... – PowerPoint PPT presentation

Number of Views:42
Avg rating:3.0/5.0
Slides: 21
Provided by: vinc56
Category:
Tags: cfml | j2ee | deploying | make | servers | up

less

Transcript and Presenter's Notes

Title: Deploying CFML on J2EE Servers


1
Deploying CFMLon J2EE Servers
  • Vince Bonfanti
  • President
  • New Atlanta Communications, LLC

2
Introduction
  • Vince Bonfanti
  • President and co-founder of New Atlanta
  • ServletExec, a Java Servlet/JSP web application
    server (1997)
  • JTurbo, a Type 4 JDBC driver for Microsoft SQL
    Server (1998)
  • BlueDragon, a CFML/JSP web application server
    (2002)
  • Member of the Java Servlet and JSP Expert Groups
  • Sun-sponsored Java Community Process for defining
    Java specs
  • Todays presentation is one in a series
  • Integrating CFML and J2EE Web Applications
    (CFNorth, May 2002)
  • Intro to JSP for CFML Developers (Atlanta CFUG,
    July 2002)
  • Deploying CFML on J2EE Servers
  • vince_at_newatlanta.com
  • Mention MDCFUG in subject or message body

3
Overview
  • Motivation Why CFML on J2EE?
  • What are Java Servlets?
  • What are JavaServer Pages (JSP)?
  • What is a J2EE Web Application (webapp)?
  • BlueDragon Architecture
  • Developing webapps that contain CFML pages
  • Deploying a webapp in an open directory on Tomcat
  • Configuring datasources
  • Deploying webapps that contain CFML pages
  • Using the BlueDragon WAR Deployment Wizard
  • Creating CFML compiled binaries (deploying
    without CFML source!)
  • Deploying a WAR file onto BEA WebLogic

4
Why CFML on J2EE?
  • Many companies are standardizing on J2EE for
    their web application infrastructure (Internet
    and intranet)
  • In-house corporate developers may be faced with
    top-down corporate decision to migrate to J2EE
  • CFML consultants and solutions providers may be
    faced with client demands for J2EE-compatible
    solutions
  • Existing CFML applications can be migrated to
    J2EE
  • ColdFusion servers can be retired without
    rewriting CFML to JSP
  • Benefits of J2EE scalability, robustness,
    reliability, portability can be realized
    immediately for CFML applications
  • CFML is a legitimate presentation-layer
    technology for J2EE development
  • CFML is superior to JSP in many ways
  • CFML can provide full integration with J2EE
    technologies

5
What are Java Servlets?
  • Java Servlets are alternatives to CGI and
    NSAPI/ISAPI web server extensions
  • Java Servlets are compiled code, but are loaded
    dynamically
  • .java source file gets compiled to byte code
    .class file
  • Java Servlets are the core presentation-layer
    technology for J2EE
  • JavaServer Pages (JSP) are built on Java Servlet
    plumbing
  • Velocity template engine is a Java Servlet
  • XML/XSLT transformation engines are implemented
    as servlets
  • Compiled Java Servlets (.class) are fully
    portable across J2EE servers and servlet/JSP
    engines

6
A Simple Java Servlet
  • public class DateServlet extends HttpServlet
  • public void service( HttpServletRequest request,
    HttpServletResponse response )
  • throws ServletException, IOException
  • response.setContentType( "text/html" )
  • PrintWriter out response.getWriter()
  • out.print( "lthtmlgt" )
  • out.print( "ltheadgtlttitlegtTodaylt/titlegtlt/headgt
    " )
  • out.print( "ltbodygt" )
  • out.print( "lth1gtToday is "
    java.util.Calendar.getInstance().getTime()
    "lt/h1gt" )
  • out.print( "lt/bodygt" )
  • out.print( "lt/htmlgt" )

7
DateServlet Output
8
What are JavaServer Pages?
  • JSP is a scripting-based technology
  • Similar to ASP and PHP, different than CFML
    tag-based approach
  • JSP taglibs allow programmers to create CFML-like
    custom tags
  • JSP Standard Tag Library (JSTL) recently reached
    1.0 status
  • JSP scripting language is Java
  • Do you have to know Java to write JSP pages? YES!
  • Theoretically can support other scripting
    languages, but never will
  • JSP is translated to a Java Servlet, compiled,
    executed
  • .jsp --gt .java (servlet) --gt .class (servlet)
  • JSP is another way to write servlets
  • JSP (.jsp) is portable across J2EE servers
  • Generated servlet (.java/.class) is NOT standard,
    but is proprietary to the servlet/JSP container
    that created it

9
JSP Elements
  • Scripting Elements
  • lt expression gt
  • lt scriptlet gt
  • lt! declaration gt
  • Standard Actions
  • ltjspuseBean/gt ltjspgetProperty/gt
  • ltjspinclude/gt ltjspsetProperty/gt
  • ltjspforward/gt ltjspparam/gt
  • Page Directives
  • lt_at_ page . . . gt
  • lt_at_ include . . . gt
  • lt_at_ taglib . . . gt

10
Example JSP Page
  • lt!-- This JSP pages produces output that is
    exactly equivalent to
  • the DateServlet example above --gt
  • lt_at_ page language"java" contentType"text/html"
    gt
  • lthtmlgt
  • ltheadgt
  • lttitlegtTodaylt/titlegt
  • lt/headgt
  • ltbodygt
  • lth1gtToday is ltjava.util.Calendar.getInstance().g
    etTime()gtlt/h1gt
  • lt/bodygt
  • lt/htmlgt

11
Generated Java Servlet
  • import com.newatlanta.servletexec.JSP10HttpJspPage
  • import com.newatlanta.servletexec.JSP10Servlet
  • public final class _today_xjsp extends
    JSP10HttpJspPage
  • public void _jspService( HttpServletRequest
    request, HttpServletResponse response )
  • throws ServletException, java.io.IOException
  • response.setContentType( "text/html" )
  • JspFactory na_jsp_factory
    JspFactory.getDefaultFactory()
  • PageContext pageContext
    na_jsp_factory.getPageContext( this, request,
    response,
  • "null", true, 8, true )
  • ServletConfig config pageContext.getServ
    letConfig()
  • ServletContext application
    pageContext.getServletContext()
  • Object page this
  • JspWriter out pageContext.getOut()
  • HttpSession session pageContext.getSessi
    on()

12
Generated Servlet (cont.)
  • try
  • out.print( "lthtmlgtltheadgtlttitlegtTodaylt/titl
    egtlt/headgtltbodygtlth1gtToday is " )
  • out.print( String.valueOf(
    java.util.Calendar.getInstance().getTime() ) )
  • out.print( "lt/bodygtlt/htmlgt" )
  • catch ( Throwable t )
  • pageContext.handlePageException( t )
  • finally
  • out.flush()
  • na_jsp_factory.releasePageContext(
    pageContext )

13
JSP Tag Libraries
  • JSP custom tags (taglibs) allow Java programmers
    to add CFML-like tags to JSP
  • Like Java CFX, but more powerful
  • Theoretically, taglibs can eliminate Java code
    from JSP pages
  • JSP Standard Tag Library (JSTL) 1.0 released in
    June
  • Variable creation and display (expression
    language)
  • Flow control conditional statements, loops
  • SQL Database access
  • XML processing
  • XML-compliance sometimes leads to awkward syntax
  • JSTL cant do ltCFIFgt ltCFELSEIFgt ltCFELSEgt
    lt/CFIFgt
  • JSTL cant do ltCFIF variable EQ valuegt
  • JSTL cant do ltCFSET variablevaluegt

14
JSTL SQL example
  • lt_at_ taglib prefix"sql" uri"http//java.sun.com/j
    stl/sql" gt
  • lt_at_ taglib prefix"c" uri"http//java.sun.com/jst
    l/core" gt
  • ltsqlquery var"films"
  • dataSource"jdbcodbcows,sun.jdbc
    .odbc.JdbcOdbcDriver"gt
  • SELECT FROM Films
  • lt/sqlquerygt
  • lthtmlgt
  • ltheadgtlttitlegtSQL Query Examplelt/titlegtlt/headgt
  • ltbodygt
  • ltulgt
  • ltcforEach var"film" items"films"gt
  • ltligtltcout value"film.MovieTitle"/gt
  • lt/cforEachgt
  • lt/ulgt
  • lt/bodygtlt/htmlgt

15
What is a J2EE Webapp?
  • A web application is a collection of servlets,
    html pages, classes, and other resources that
    make up a complete application on a web server.
    The web application can be bundled and run on
    multiple containers from multiple vendors.
  • -- Java Servlet Specification Version 2.3
  • A J2EE webapp is characterized by a specific
    directory structure and a configuration file
    named web.xml
  • A J2EE webapp can be bundled and deployed as a
    single component within a Web ARchive (WAR) file
  • Just a ZIP file containing the webapp with the
    .war extension

16
Webapp Directory Structure
  • A J2EE webapp consists of a single directory into
    which all content files (HTML, GIF, JPEG, JSP,
    CFML) are placed
  • This is referred to as the webapp top-level
    directory
  • May contain arbitrary subdirectories to hold
    content
  • The WEB-INF subdirectory contains files that will
    not be served to the client
  • The web.xml deployment descriptor is placed
    within the WEB-INF subdirectory
  • The WEB-INF/classes and WEB-INF/lib
    subdirectories contain Java .class and .jar files
    (these could contain servlets, JSP tag libraries,
    JDBC drivers, etc.)

17
Webapp Context Path
  • When deploying a webapp, the J2EE server needs to
    know two things
  • The location of the webapp directory or WAR file
  • The URL Context Path used to specify the webapp
  • The URL Context Path is similar to a virtual
    directory
  • All URLs that start with the Context Path are
    mapped to the webapp for processing
  • http//www.newatlanta.com/contextPath/index.jsp
  • Using Context Paths allows multiple web
    applications to be deployed on a single J2EE
    server
  • Web applications are completely independent

18
BlueDragon Architecture
  • BlueDragon is CFML runtime that is implemented as
    a standard Java Servlet
  • The BlueDragon runtime servlet can be built into
    a standard J2EE webapp
  • web.xml is configured to direct processing for
    all .cfm pages to the BlueDragon servlet
  • Just add CFML (.cfm) pages and deploy!
  • BlueDragon compiles CFML pages into an internal
    representation that is cached and executed from
    RAM
  • Compiled CFML pages can be stored and deployed in
    files called BlueDragon Archives (BDA)
  • No need to deploy CFML source files

19
Demonstration
  • The worlds simplest J2EE webapp
  • Manually creating a WAR file
  • The BlueDragon webapp template
  • Developing webapps that contain CFML pages
  • Deploying as an open directory on Tomcat
  • Configuring datasources
  • Deploying webapps that contain CFML pages
  • Using the BlueDragon WAR Deployment Wizard
  • Creating compiled BDA archives
  • Deploying a WAR file on BEA WebLogic

20
BlueDragon vs CFMX
  • Demonstration shows four things that
    BlueDragon/J2EE can do today that CFMX/J2EE
    cannot
  • Deploy on Tomcat
  • Create a WAR file that can be deployed onto any
    standard J2EE application server
  • Create CFML compiled binary archives (BDA) that
    can be deployed instead of CFML source files
  • Deploy WAR files to BEA WebLogic
Write a Comment
User Comments (0)
About PowerShow.com