Marrying Java & ColdFusion

clangpotatoSoftware and s/w Development

Oct 28, 2013 (3 years and 7 months ago)

103 views

www.systemanage.com

+





1

Getting Started with WAP and WML

Marrying Java &
ColdFusion


Charles Arehart

Founder/CTO, Systemanage

carehart@systemanage.com

© 2001 Charles Arehart,

www.systemanage.com

Getting Started with WAP and WML

2

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

www.systemanage.com

Getting Started with WAP and WML

3

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

www.systemanage.com

Getting Started with WAP and WML

4

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



www.systemanage.com

Getting Started with WAP and WML

5

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

www.systemanage.com

Getting Started with WAP and WML

6

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

www.systemanage.com

Getting Started with WAP and WML

7

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

www.systemanage.com

Getting Started with WAP and WML

8

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


www.systemanage.com

Getting Started with WAP and WML

9

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



www.systemanage.com

Getting Started with WAP and WML

10

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.

www.systemanage.com

Getting Started with WAP and WML

11

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.

www.systemanage.com

Getting Started with WAP and WML

12

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

www.systemanage.com

Getting Started with WAP and WML

13

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


www.systemanage.com

Getting Started with WAP and WML

14

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

www.systemanage.com

Getting Started with WAP and WML

15

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

www.systemanage.com

Getting Started with WAP and WML

16

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



www.systemanage.com

Getting Started with WAP and WML

17

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


www.systemanage.com

Getting Started with WAP and WML

18

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

www.systemanage.com

Getting Started with WAP and WML

19

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

www.systemanage.com

Getting Started with WAP and WML

20

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

www.systemanage.com

Getting Started with WAP and WML

21

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

www.systemanage.com

Getting Started with WAP and WML

22

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

www.systemanage.com

Getting Started with WAP and WML

23

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

www.systemanage.com

Getting Started with WAP and WML

24

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

www.systemanage.com

Getting Started with WAP and WML

25

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

www.systemanage.com

Getting Started with WAP and WML

26

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

www.systemanage.com

Getting Started with WAP and WML

27

For Further Questions


For follow
-
up questions


Or more information on Java or ColdFusion consulting, training,
or presentations


Please contact:


Charlie Arehart, CTO, Systemanage


carehart@systemanage.com


(voice) 301 604 8399


http://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