1 / 20

Deploying CFML on J2EE Servers

Deploying CFML on J2EE Servers. Vince Bonfanti President New Atlanta Communications, LLC. 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)

teo
Download Presentation

Deploying CFML on J2EE Servers

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  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 • Today’s 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@newatlanta.com • Mention MDCFUG in subject or message body Deploying CFML on J2EE Servers

  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 Deploying CFML on J2EE Servers

  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 Deploying CFML on J2EE Servers

  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 Deploying CFML on J2EE Servers

  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( "<html>" ); out.print( "<head><title>Today</title></head>" ); out.print( "<body>" ); out.print( "<h1>Today is " + java.util.Calendar.getInstance().getTime() + "</h1>" ); out.print( "</body>" ); out.print( "</html>" ); } } Deploying CFML on J2EE Servers

  7. DateServlet Output Deploying CFML on J2EE Servers

  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 --> .java (servlet) --> .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 Deploying CFML on J2EE Servers

  9. JSP Elements • Scripting Elements <%= expression %> <% scriptlet %> <%! declaration %> • Standard Actions <jsp:useBean/> <jsp:getProperty/> <jsp:include/> <jsp:setProperty/> <jsp:forward/> <jsp:param/> • Page Directives <%@ page . . . %> <%@ include . . . %> <%@ taglib . . . %> Deploying CFML on J2EE Servers

  10. Example JSP Page <!-- This JSP pages produces output that is exactly equivalent to the DateServlet example above --> <%@ page language="java" contentType="text/html" %> <html> <head> <title>Today</title> </head> <body> <h1>Today is <%=java.util.Calendar.getInstance().getTime()%></h1> </body> </html> Deploying CFML on J2EE Servers

  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.getServletConfig(); ServletContext application = pageContext.getServletContext(); Object page = this; JspWriter out = pageContext.getOut(); HttpSession session = pageContext.getSession(); Deploying CFML on J2EE Servers

  12. Generated Servlet (cont.) try { out.print( "<html><head><title>Today</title></head><body><h1>Today is " ); out.print( String.valueOf( java.util.Calendar.getInstance().getTime() ) ); out.print( "</body></html>" ); } catch ( Throwable t ) { pageContext.handlePageException( t ); } finally { out.flush(); na_jsp_factory.releasePageContext( pageContext ); } } } Deploying CFML on J2EE Servers

  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 can’t do <CFIF> … <CFELSEIF> … <CFELSE> … </CFIF> • JSTL can’t do <CFIF variable EQ value> • JSTL can’t do <CFSET variable=value> Deploying CFML on J2EE Servers

  14. JSTL – SQL example <%@ taglib prefix="sql" uri="http://java.sun.com/jstl/sql" %> <%@ taglib prefix="c" uri="http://java.sun.com/jstl/core" %> <sql:query var="films" dataSource="jdbc:odbc:ows,sun.jdbc.odbc.JdbcOdbcDriver"> SELECT * FROM Films </sql:query> <html> <head><title>SQL Query Example</title></head> <body> <ul> <c:forEach var="film" items="${films}"> <li><c:out value="${film.MovieTitle}"/> </c:forEach> </ul> </body></html> Deploying CFML on J2EE Servers

  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 Deploying CFML on J2EE Servers

  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.) Deploying CFML on J2EE Servers

  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 Deploying CFML on J2EE Servers

  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 Deploying CFML on J2EE Servers

  19. Demonstration • The world’s 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 Deploying CFML on J2EE Servers

  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 Deploying CFML on J2EE Servers

More Related