www.systemanage.com + 1getting started with wap and wml marrying java & coldfusion charles...

27
1 www.systemanage.com Getting Started with WAP and WML + Marrying Java & ColdFusion Charles Arehart Founder/CTO, Systemanage [email protected] © 2001 Charles Arehart,

Upload: christopher-kennedy

Post on 25-Dec-2015

215 views

Category:

Documents


1 download

TRANSCRIPT

Page 1: Www.systemanage.com + 1Getting Started with WAP and WML Marrying Java & ColdFusion Charles Arehart Founder/CTO, Systemanage carehart@systemanage.com ©

1 www.systemanage.comGetting Started with WAP and WML

+

       Marrying Java & ColdFusion

Charles ArehartFounder/CTO, [email protected]

© 2001 Charles Arehart,

Page 2: Www.systemanage.com + 1Getting Started with WAP and WML Marrying Java & ColdFusion Charles Arehart Founder/CTO, Systemanage carehart@systemanage.com ©

Getting Started with WAP and WML2 www.systemanage.com

Agenda

• Considering Java as an alternative • Integrating CF and Java Today

– CFOBJECT, CFX_ Custom tags, CFServlet• Jrun and Java Application Servers

– JSP/Servlets, EJBs, and more• Future integration possibilities for CF’ers• TagServlet from n-ary.com• Software Needed• Learning More

Page 3: Www.systemanage.com + 1Getting Started with WAP and WML Marrying Java & ColdFusion Charles Arehart Founder/CTO, Systemanage carehart@systemanage.com ©

Getting Started with WAP and WML3 www.systemanage.com

Audience

• Intended primarily for those with:– ColdFusion experience– Aware of Java and its value to application developers

• No need for java experience• Enterprise integration experience not necessary

• Anyone interested in:– Learning about Java integrating ColdFusion & Java– Extending CF into existing enterprise applications– Will likely come away capable of doing it immediately

Page 4: Www.systemanage.com + 1Getting Started with WAP and WML Marrying Java & ColdFusion Charles Arehart Founder/CTO, Systemanage carehart@systemanage.com ©

Getting Started with WAP and WML4 www.systemanage.com

Who Am I?

• A programmer by trade, trainer at heart– with nearly 20 years IT experience

• 4 years ColdFusion, 1 year server-side Java

– Monthly contributor to ColdFusion Developer Journal– Speaker at user groups, conferences worldwide– Allaire Certified Instructor & Developer

• Best practices, performance tuning consultant– Contract mentor to development teams

Page 5: Www.systemanage.com + 1Getting Started with WAP and WML Marrying Java & ColdFusion Charles Arehart Founder/CTO, Systemanage carehart@systemanage.com ©

Getting Started with WAP and WML5 www.systemanage.com

Our Goal

• Java integration is both simple and broad– Can’t expect to cover everything today (or even an

entire week)• Not even a single book can capture it all

– Will introduce most important topics• Get a flavor for opportunities, challenges• Understand fundamentals

– Will discuss• How to begin• Explore resources for learning more

Page 6: Www.systemanage.com + 1Getting Started with WAP and WML Marrying Java & ColdFusion Charles Arehart Founder/CTO, Systemanage carehart@systemanage.com ©

Getting Started with WAP and WML6 www.systemanage.com

Considering Java as an alternative• Java: it’s here & it’s big• May have been feeling pull

– May have been able to “fight” getting into it– Time has come to face the truth

• A large market is demanding Enterprise java solutions

• Not really about caving in– Learning how and when to best leverage Java as a CF

developer– Not necessarily leaving CF for Java– More about how to best marry the two

• Getting easier all the time

• Free to get started– Most platform tools are free, for developer level

deployment

Page 7: Www.systemanage.com + 1Getting Started with WAP and WML Marrying Java & ColdFusion Charles Arehart Founder/CTO, Systemanage carehart@systemanage.com ©

Getting Started with WAP and WML7 www.systemanage.com

Why Bother?

• Benefits for current projects– Leveraging java library functions for quick needs– Creating new classes to extend functionality– Accessing existing apps/modules within enterprise

• Whether written in java (as classes, EJB’s, servlets)• Or made available by way of it (CORBA)

• Benefits as a professional developer or development firm– Lots more clients clamoring for JSP/servlets than CF

• Still plenty of market for CF, just larger for JSP/servlets

– Skills learned in working with Jrun migrate for the most part to other java application servers

• IBM Websphere, BEA WebLogic, Apache TomCat

Page 8: Www.systemanage.com + 1Getting Started with WAP and WML Marrying Java & ColdFusion Charles Arehart Founder/CTO, Systemanage carehart@systemanage.com ©

Getting Started with WAP and WML8 www.systemanage.com

What Can Java Give Us?

• Among the things Java can offer CF developers, besides primarily Enterprise integration include:– Stronger string manipulation– XML manipulation– Networking– Compression– Encryption – Graphics generation– Image creation and manipulation– PDF creation and formatting

• Allaire Tag Gallery and Sun site offer downloadable examples of such things

Page 9: Www.systemanage.com + 1Getting Started with WAP and WML Marrying Java & ColdFusion Charles Arehart Founder/CTO, Systemanage carehart@systemanage.com ©

Getting Started with WAP and WML9 www.systemanage.com

Integrating CF and Java Today

• CFOBJECT for Java– Used to call upon java classes available on the same

server running CF• Can be used to leverage java language• Or to access existing business objects, including EJB’s

• CFX_ Java Custom tags– Similar to calling via CFOBJECT

• Typically used to leverage CF integration within the Java class (accessing/updating CF variables, queries, etc.)

– Like CFX’s in C++, can leverage the CFX API• CFServlet

– Used to integrate with servlets• Either obtaining the output of the servlet• Or creating means to pass data to servlet which it can

manipulate

Page 10: Www.systemanage.com + 1Getting Started with WAP and WML Marrying Java & ColdFusion Charles Arehart Founder/CTO, Systemanage carehart@systemanage.com ©

Getting Started with WAP and WML10 www.systemanage.com

Simpler Forms of Integration

• Keep in mind that servlets (and JSPs) can also be called from within CF templates just as regular HTML pages could:– <A href>– <cflocation>– <form action=>– <img src>– Etc.

Page 11: Www.systemanage.com + 1Getting Started with WAP and WML Marrying Java & ColdFusion Charles Arehart Founder/CTO, Systemanage carehart@systemanage.com ©

Getting Started with WAP and WML11 www.systemanage.com

Installation Support for Java Integration• To leverage CFOBJECT for Java and CFX

– you must have 4.5.1 of ColdFusion– Must have Java Runtime Environment 1.2– Must configure CF server Admin to setup classpath

and other parameters• Critical points are

– JVM path: where JVM is installed– Classpath: where your classes will be stored– CFX_jar path: where cfx.jar for CFX’s will be stored

• See “A Cold Cup O’ Joe” Part 1 – Jan 01 CFDJ– Great discussion of setup issues, challenges

• See later slide “Software Needed” for how to obtain software, versions, etc.

Page 12: Www.systemanage.com + 1Getting Started with WAP and WML Marrying Java & ColdFusion Charles Arehart Founder/CTO, Systemanage carehart@systemanage.com ©

Getting Started with WAP and WML12 www.systemanage.com

CFOBJECT for Java

• New support in 4.5 for CFOBJECT Type=“Java”– Also createobject() function for use in CFSCRIPT

• Allows call to java objects– There are even graphing objects that can be called

• Fairly easy to demonstrate simple example– Just need to know its methods and attributes

Page 13: Www.systemanage.com + 1Getting Started with WAP and WML Marrying Java & ColdFusion Charles Arehart Founder/CTO, Systemanage carehart@systemanage.com ©

Getting Started with WAP and WML13 www.systemanage.com

CFObject (cont)

• For more complex uses– Need to understand calling an object’s default

constructor or overloaded constructors• Does not currently support overload by attribute datatype

– Great discussion in “Cold Cup O’ Joe” Part 3• April 01 CFDJ

• Can also be used to call Enterprise Java Beans– Demonstrated in Allaire “Developing Applications with

Jrun”, chapter 42

Page 14: Www.systemanage.com + 1Getting Started with WAP and WML Marrying Java & ColdFusion Charles Arehart Founder/CTO, Systemanage carehart@systemanage.com ©

Getting Started with WAP and WML14 www.systemanage.com

CFX_ Java Custom Tags

• Similar to calling upon objects– The class that is called can read/manipulate CF

elements• Variables, queries• See simple example

– Can also pass it attributes• Processed with request.getAttribute in class• See simple example

• Must be registered in the CF administrator– Then called as <cfx_ojectname>

• Available Debugging option– See simple example

• May hear of old way of doing this, CFX_J

Page 15: Www.systemanage.com + 1Getting Started with WAP and WML Marrying Java & ColdFusion Charles Arehart Founder/CTO, Systemanage carehart@systemanage.com ©

Getting Started with WAP and WML15 www.systemanage.com

Java CFX Interface

• Several available methods, attributes for developing java Custom Tags – Query interface– Request Interface– Response Interface

• See “Developing Web Apps” for details– Chapter 18

Page 16: Www.systemanage.com + 1Getting Started with WAP and WML Marrying Java & ColdFusion Charles Arehart Founder/CTO, Systemanage carehart@systemanage.com ©

Getting Started with WAP and WML16 www.systemanage.com

CFServlet

• Only works with Jrun• Allows call to servlet running under Jrun

– Need only know• Server’s IP address, if not same as CF server• Jrun Port (Jrun and other app servers use unique ports to distinguish

from web server)• Servlet name

– <CFSERVLET code="SimpleServlet" jrunproxy="127.0.0.1:8100">

• Optional WriteOutput=“yes/no” attribute– If no, output of servlet is written to CF output stream– If yes, written to Cfservlet.output variable

• Optional Debug=“yes/no” attribute– Can write to a Jrun-specific event log file

• May hear of old way of doing this: CF_Servlet

Page 17: Www.systemanage.com + 1Getting Started with WAP and WML Marrying Java & ColdFusion Charles Arehart Founder/CTO, Systemanage carehart@systemanage.com ©

Getting Started with WAP and WML17 www.systemanage.com

CFServlet

• Allows passing data by value or reference– By value:

• <cfservletparam name=“servletparm” value=“value”>• Available to servlet as “parameter”• Changing parameter in servlet has no effect on CF variable

– By reference:• <cfservletparam name=“servletattr” variable=“CFVarname”>• Optional “type” attribute to help CF tell java the datatype• Available to servlet as “attribute”• Changing attribute value in servlet will change CF variable

Page 18: Www.systemanage.com + 1Getting Started with WAP and WML Marrying Java & ColdFusion Charles Arehart Founder/CTO, Systemanage carehart@systemanage.com ©

Getting Started with WAP and WML18 www.systemanage.com

Message Passing

• When considering communications between CF and java components, consider XML– XML provides powerful means to pass structured data

between disparate systems– Need not be Allaire’s WDDX format

• If you control the two systems talking to each other, you can create your own meaning in the XML

– See “Online Ticket Store” in Jan 2000 CFDJ

Page 19: Www.systemanage.com + 1Getting Started with WAP and WML Marrying Java & ColdFusion Charles Arehart Founder/CTO, Systemanage carehart@systemanage.com ©

Getting Started with WAP and WML19 www.systemanage.com

Jrun and Java Application Servers• Jrun is a Java Application Server

– And a very well respected one, at that– Reasonably priced, free developer edition

• Others include– IBM Websphere– BEA Weblogic– Apache TomCat

• Enables execution of Java Server Pages, servlets– JRUN also includes features to run EJBs, and more

• JSP’s ease entry into Java world

Page 20: Www.systemanage.com + 1Getting Started with WAP and WML Marrying Java & ColdFusion Charles Arehart Founder/CTO, Systemanage carehart@systemanage.com ©

Getting Started with WAP and WML20 www.systemanage.com

Java Editors

• Big difference between JSP editor and Java Servlet/Class editor– CF Studio can act as JSP editor

• Knows about JSP tags, etc.

– Kawa is a real Java editor• Can compile things, debug, etc.

– Jrun Studio is a hybrid• Adds ability to compile to CF Studio interface• Not nearly as powerful as Kawa for real Java editing

– Other java editors don’t likely support JSP’s/servlets• Visual café, Visual J++, etc.• JPadPro available as shareware

Page 21: Www.systemanage.com + 1Getting Started with WAP and WML Marrying Java & ColdFusion Charles Arehart Founder/CTO, Systemanage carehart@systemanage.com ©

Getting Started with WAP and WML21 www.systemanage.com

Future integration possibilities for CF’ers• ColdFusion 6, a.k.a Neo

– Changing CF from running on a C++ platform to running on a Java platform

– Does NOT propose to change CF developers into Java developers

• CF templates will run unchanged• Under the cover, will be turned into Java Servlets

– Will further open integration possibilities– More important for Allaire

• Allows them to leverage the Java platform– And many features that they currently must build from

scratch to make CF as powerful as it is

Page 22: Www.systemanage.com + 1Getting Started with WAP and WML Marrying Java & ColdFusion Charles Arehart Founder/CTO, Systemanage carehart@systemanage.com ©

Getting Started with WAP and WML22 www.systemanage.com

TagServlet from n-ary.com

• Very similar to proposed Neo approach– But works today

• Can process a ColdFusion file and turn it into a servlet to be executed– Has more limited tag support than Neo proposes

• Is improving all the time

• Currently in beta, will eventually be sold• Called TagFusion for a time

Page 23: Www.systemanage.com + 1Getting Started with WAP and WML Marrying Java & ColdFusion Charles Arehart Founder/CTO, Systemanage carehart@systemanage.com ©

Getting Started with WAP and WML23 www.systemanage.com

Getting to EJB’s

• By now can see at least 2 routes to EJB’s– CFOBJECT direct call to EJB– CFSERVLET call to servlet, that calls EJB

• In case such interaction already exists and don’t want to code more direct route

Page 24: Www.systemanage.com + 1Getting Started with WAP and WML Marrying Java & ColdFusion Charles Arehart Founder/CTO, Systemanage carehart@systemanage.com ©

Getting Started with WAP and WML24 www.systemanage.com

Software Needed

• To do any java integration, need Java Runtime Engine on server– Can obtain free from javasoft.com

• To run Jrun or do JSP/servlet integration, will need a Java application server– Allaire offers free 3 person developer edition– Will need Java 2 EE (J2EE) SDK on top of that

• Also free from javasoft.com– Other java app servers from IBM, BEA (beasys.com),

Apache Tomcat (apache.org)• To do EJB integration, need EJB server

– Jrun provides that, as do other products• ColdFusion 4.5

– added java custom tags and CFObject support for java

Page 25: Www.systemanage.com + 1Getting Started with WAP and WML Marrying Java & ColdFusion Charles Arehart Founder/CTO, Systemanage carehart@systemanage.com ©

Getting Started with WAP and WML25 www.systemanage.com

Learning More

• Many CFDJ articles– Especially current 8 part “Cold Cup O’ Joe” series by

Guy Risch– 3 part “Java for CF’ers” series by Ben Forta– 6 part “Online Ticket Store” series by Ajit Sagar

• 4 parts of which were in Java Dev. Journal

• Allaire documentation – CFObject, CFX_ custom tags, CFServlet– Language Reference and “Developing Web Apps”– Administering CF (for admin setup)

• Excellent Allaire Jrun documentation– Download the Allaire Jrun 3-user demo– No time expiration

Page 26: Www.systemanage.com + 1Getting Started with WAP and WML Marrying Java & ColdFusion Charles Arehart Founder/CTO, Systemanage carehart@systemanage.com ©

Getting Started with WAP and WML26 www.systemanage.com

Beware of Some Books

• May focus on teaching servlets/JSP to java developers– Focus more on showing them how to do web

application development (stateless programming, passing data from URL’s and forms, etc.)

– Presume that reader already knows Java• Java Books often focus too much on client-

side Java (applets, Swing)– Not as relevant to us interested in server-side java

Page 27: Www.systemanage.com + 1Getting Started with WAP and WML Marrying Java & ColdFusion Charles Arehart Founder/CTO, Systemanage carehart@systemanage.com ©

Getting Started with WAP and WML27 www.systemanage.com

For Further Questions

• For follow-up questions – Or more information on Java or ColdFusion consulting, training,

or presentations

• Please contact:Charlie Arehart, CTO, [email protected](voice) 301 604 8399http://www.systemanage.com

• Available for training, mentoring, short-term consulting (1-5 days):– All manner of CF topics, beginner-adv– Maximizing developer productivity– Best practices, performance tuning– Database design, Int/Adv SQL topics– Testing, Source Code Control, and more– Wireless development training