Скачать презентацию Deploying CFML on J 2 EE Servers Vince Скачать презентацию Deploying CFML on J 2 EE Servers Vince

014be9f126b7fd0b6b587c14f744fbf4.ppt

  • Количество слайдов: 20

Deploying CFML on J 2 EE Servers Vince Bonfanti President New Atlanta Communications, LLC Deploying CFML on J 2 EE Servers Vince Bonfanti President New Atlanta Communications, LLC

Introduction n n Vince Bonfanti President and co-founder of New Atlanta n n Member Introduction n n Vince Bonfanti President and co-founder of New Atlanta n n Member of the Java Servlet and JSP Expert Groups n n Sun-sponsored Java Community Process for defining Java specs Today’s presentation is one in a series: n n Servlet. Exec, a Java Servlet/JSP web application server (1997) JTurbo, a Type 4 JDBC driver for Microsoft SQL Server (1998) Blue. Dragon, a CFML/JSP web application server (2002) Integrating CFML and J 2 EE Web Applications (CFNorth, May 2002) Intro to JSP for CFML Developers (Atlanta CFUG, July 2002) Deploying CFML on J 2 EE Servers vince@newatlanta. com n Mention MDCFUG in subject or message body MDCFUG – September 10, 2002 Deploying CFML on J 2 EE Servers 1

Overview n n n Motivation: Why CFML on J 2 EE? What are Java Overview n n n Motivation: Why CFML on J 2 EE? What are Java Servlets? What are Java. Server Pages (JSP)? What is a J 2 EE Web Application (webapp)? Blue. Dragon Architecture Developing webapps that contain CFML pages n n n Deploying a webapp in an open directory on Tomcat Configuring datasources Deploying webapps that contain CFML pages n n n Using the Blue. Dragon WAR Deployment Wizard Creating CFML compiled binaries (deploying without CFML source!) Deploying a WAR file onto BEA Web. Logic MDCFUG – September 10, 2002 Deploying CFML on J 2 EE Servers 2

Why CFML on J 2 EE? n Many companies are standardizing on J 2 Why CFML on J 2 EE? n Many companies are standardizing on J 2 EE for their web application infrastructure (Internet and intranet) n n n Existing CFML applications can be migrated to J 2 EE n n n In-house corporate developers may be faced with top-down corporate decision to migrate to J 2 EE CFML consultants and solutions providers may be faced with client demands for J 2 EE-compatible solutions Cold. Fusion servers can be retired without rewriting CFML to JSP Benefits of J 2 EE scalability, robustness, reliability, portability can be realized immediately for CFML applications CFML is a legitimate presentation-layer technology for J 2 EE development n n CFML is superior to JSP in many ways CFML can provide full integration with J 2 EE technologies MDCFUG – September 10, 2002 Deploying CFML on J 2 EE Servers 3

What are Java Servlets? n n Java Servlets are alternatives to CGI and NSAPI/ISAPI What are Java Servlets? n n Java Servlets are alternatives to CGI and NSAPI/ISAPI web server extensions Java Servlets are compiled code, but are loaded dynamically n n Java Servlets are the core presentation-layer technology for J 2 EE n n . java source file gets compiled to byte code. class file Java. Server 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 J 2 EE servers and servlet/JSP engines MDCFUG – September 10, 2002 Deploying CFML on J 2 EE Servers 4

A Simple Java Servlet public class Date. Servlet extends Http. Servlet { public void A Simple Java Servlet public class Date. Servlet extends Http. Servlet { public void service( Http. Servlet. Request request, Http. Servlet. Response response ) throws Servlet. Exception, IOException { response. set. Content. Type( "text/html" ); Print. Writer out = response. get. Writer(); out. print( "" ); "Today" ); "" ); "Today is " + java. util. Calendar. get. Instance(). get. Time() + "" ); "" ); "" ); } } MDCFUG – September 10, 2002 Deploying CFML on J 2 EE Servers 5

Date. Servlet Output MDCFUG – September 10, 2002 Deploying CFML on J 2 EE Date. Servlet Output MDCFUG – September 10, 2002 Deploying CFML on J 2 EE Servers 6

What are Java. Server Pages? n JSP is a scripting-based technology n n JSP What are Java. Server Pages? n JSP is a scripting-based technology n n JSP scripting language is Java n n n 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 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 n n n . jsp -->. java (servlet) -->. class (servlet) JSP is “another way to write servlets” JSP (. jsp) is portable across J 2 EE servers n Generated servlet (. java/. class) is NOT standard, but is proprietary to the servlet/JSP container that created it MDCFUG – September 10, 2002 Deploying CFML on J 2 EE Servers 7

JSP Elements n Scripting Elements <%= expression %> <% scriptlet %> <%! declaration %> JSP Elements n Scripting Elements <%= expression %> <% scriptlet %> <%! declaration %> n Standard Actions n Page Directives <%@ page. . . %> <%@ include. . . %> <%@ taglib. . . %> MDCFUG – September 10, 2002 Deploying CFML on J 2 EE Servers 8

Example JSP Page <!-- This JSP pages produces output that is exactly equivalent to Example JSP Page <%@ page language="java" content. Type="text/html" %> Today Today is <%=java. util. Calendar. get. Instance(). get. Time()%> MDCFUG – September 10, 2002 Deploying CFML on J 2 EE Servers 9

Generated Java Servlet import com. newatlanta. servletexec. JSP 10 Http. Jsp. Page; import com. Generated Java Servlet import com. newatlanta. servletexec. JSP 10 Http. Jsp. Page; import com. newatlanta. servletexec. JSP 10 Servlet; public final class _today_xjsp extends JSP 10 Http. Jsp. Page { public void _jsp. Service( Http. Servlet. Request request, Http. Servlet. Response response ) throws Servlet. Exception, java. io. IOException { response. set. Content. Type( "text/html" ); Jsp. Factory na_jsp_factory = Jsp. Factory. get. Default. Factory(); Page. Context page. Context = na_jsp_factory. get. Page. Context( this, request, response, "null", true, 8, true ); Servlet. Config config = page. Context. get. Servlet. Config(); Servlet. Context application = page. Context. get. Servlet. Context(); Object page = this; Jsp. Writer out = page. Context. get. Out(); Http. Session session = page. Context. get. Session(); MDCFUG – September 10, 2002 Deploying CFML on J 2 EE Servers 10

TodayToday is " ); out." src="https://present5.com/presentation/014be9f126b7fd0b6b587c14f744fbf4/image-12.jpg" alt="Generated Servlet (cont. ) try { out. print( "TodayToday is " ); out." /> Generated Servlet (cont. ) try { out. print( "TodayToday is " ); out. print( String. value. Of( java. util. Calendar. get. Instance(). get. Time() ) ); out. print( "" ); } catch ( Throwable t ) { page. Context. handle. Page. Exception( t ); } finally { out. flush(); na_jsp_factory. release. Page. Context( page. Context ); } } } MDCFUG – September 10, 2002 Deploying CFML on J 2 EE Servers 11

JSP Tag Libraries n JSP custom tags (taglibs) allow Java programmers to add CFML-like JSP Tag Libraries n JSP custom tags (taglibs) allow Java programmers to add CFML-like tags to JSP n n n JSP Standard Tag Library (JSTL) 1. 0 released in June n n n Like Java CFX, but more powerful Theoretically, taglibs can eliminate Java code from JSP pages Variable creation and display (expression language) Flow control: conditional statements, loops SQL Database access XML processing XML-compliance sometimes leads to awkward syntax n n n JSTL can’t do JSTL can’t do JSTL can’t do MDCFUG – September 10, 2002 Deploying CFML on J 2 EE Servers 12

<%@ taglib" src="https://present5.com/presentation/014be9f126b7fd0b6b587c14f744fbf4/image-14.jpg" alt="JSTL – SQL example <%@ taglib prefix="sql" uri="http: //java. sun. com/jstl/sql" %> <%@ taglib" /> JSTL – SQL example <%@ taglib prefix="sql" uri="http: //java. sun. com/jstl/sql" %> <%@ taglib prefix="c" uri="http: //java. sun. com/jstl/core" %> SELECT * FROM Films SQL Query Example

MDCFUG – September 10, 2002 Deploying CFML on J 2 EE Servers 13

What is a J 2 EE Webapp? n n n “A web application is What is a J 2 EE Webapp? n n n “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 J 2 EE webapp is characterized by a specific directory structure and a configuration file named web. xml A J 2 EE webapp can be bundled and deployed as a single component within a Web ARchive (WAR) file n Just a ZIP file containing the webapp with the “. war” extension MDCFUG – September 10, 2002 Deploying CFML on J 2 EE Servers 14

Webapp Directory Structure n A J 2 EE webapp consists of a single directory Webapp Directory Structure n A J 2 EE webapp consists of a single directory into which all content files (HTML, GIF, JPEG, JSP, CFML) are placed n n n 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. ) MDCFUG – September 10, 2002 Deploying CFML on J 2 EE Servers 15

Webapp Context Path n When deploying a webapp, the J 2 EE server needs Webapp Context Path n When deploying a webapp, the J 2 EE server needs to know two things: n n 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/context. Path/index. jsp n Using Context Paths allows multiple web applications to be deployed on a single J 2 EE server n Web applications are completely independent MDCFUG – September 10, 2002 Deploying CFML on J 2 EE Servers 16

Blue. Dragon Architecture n n Blue. Dragon is CFML runtime that is implemented as Blue. Dragon Architecture n n Blue. Dragon is CFML runtime that is implemented as a standard Java Servlet The Blue. Dragon runtime servlet can be built into a standard J 2 EE webapp n n web. xml is configured to direct processing for all “. cfm” pages to the Blue. Dragon servlet Just add CFML (“. cfm”) pages and deploy! Blue. Dragon 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 Blue. Dragon Archives (BDA) n No need to deploy CFML source files MDCFUG – September 10, 2002 Deploying CFML on J 2 EE Servers 17

Demonstration n The world’s simplest J 2 EE webapp n n n The Blue. Demonstration n The world’s simplest J 2 EE webapp n n n The Blue. Dragon webapp template Developing webapps that contain CFML pages n n n Manually creating a WAR file Deploying as an open directory on Tomcat Configuring datasources Deploying webapps that contain CFML pages n n n Using the Blue. Dragon WAR Deployment Wizard Creating compiled BDA archives Deploying a WAR file on BEA Web. Logic MDCFUG – September 10, 2002 Deploying CFML on J 2 EE Servers 18

Blue. Dragon vs CFMX n Demonstration shows four things that Blue. Dragon/J 2 EE Blue. Dragon vs CFMX n Demonstration shows four things that Blue. Dragon/J 2 EE can do today that CFMX/J 2 EE cannot: n n Deploy on Tomcat Create a WAR file that can be deployed onto any standard J 2 EE application server Create CFML compiled binary archives (BDA) that can be deployed instead of CFML source files Deploy WAR files to BEA Web. Logic MDCFUG – September 10, 2002 Deploying CFML on J 2 EE Servers 19