Comments
Richard Davies wrote: The UK has a good crop of technology pioneers in cloud computing - for example ElasticHosts, FlexiScale, Flexiant, OnApp - and also some strong government initiatives such as G-Cloud. We will have to see whether this kind of technical leadership converts into swift mass-market adoption or not.
Cloud Expo on Google News

SYS-CON.TV
Cloud Expo & Virtualization 2009 East
PLATINUM SPONSORS:
IBM
Smarter Business Solutions Through Dynamic Infrastructure
IBM
Smarter Insights: How the CIO Becomes a Hero Again
Microsoft
Windows Azure
GOLD SPONSORS:
Appsense
Why VDI?
CA
Maximizing the Business Value of Virtualization in Enterprise and Cloud Computing Environments
ExactTarget
Messaging in the Cloud - Email, SMS and Voice
Freedom OSS
Stairway to the Cloud
Sun
Sun's Incubation Platform: Helping Startups Serve the Enterprise
POWER PANELS:
Cloud Computing & Enterprise IT: Cost & Operational Benefits
How and Why is a Flexible IT Infrastructure the Key To the Future?
Click For 2008 West
Event Webcasts
Extending ColdFusion with Java Servlets and JRun
Extending ColdFusion with Java Servlets and JRun

The ColdFusion Markup Language is the easiest way to generate dynamic Web content from a database. Its tag-based scripting commands are simple for HTML authors to learn, yet powerful enough for building full-featured Web applications. Custom ColdFusion tags can be developed in either CFML or C++ using the CFX plug-in API.

Java servlets are becoming the most effective way to build server-side Web plug-ins. Because servlets are written in Java, they can run just about anywhere and connect to nearly anything. They're faster than CGI scripts and easier to write than native platform plug-ins such as Microsoft's Internet Server API (ISAPI), Netscape's Server API (NSAPI) and CFX. You can write entire applications with servlets or use them as "web glue" to "webify" anything from a printer to a mainframe.

JRun is the award-winning, industry-leading servlet engine for developing and deploying Java servlets. It's an easy-to-use Web server plug-in that allows you to deploy Java servlets and JavaServer Pages (JSP). JRun was developed by Live Software, which was recently acquired by Allaire Corporation. For more information on JRun and to download a free copy visit www.livesoftware.com.

With a few simple examples this article will demonstrate how easy it is to invoke Java servlets within your CFML pages using JRun.

CF_SERVLET
Anyone familiar with the <SERVLET> tag will immediately understand <CF_SERVLET>. It invokes the named servlet running on JRun, and the results are included in the output of the page. Common HTTP headers and tag attributes are available to the servlet using the ServletRequest.getParameter() method.

For example, let's say we want to invoke JRun's EmailLiteServlet (included in the JRun Servlet Pack One) to send an e-mail after a form submission. Using NCSA-style Server Side Includes (SSI), the invocation would look as follows:

<SERVLET CODE=EmailLiteServlet>
<PARAM NAME="host" VALUE="pop.somehost.com">
<PARAM NAME="dest" VALUE="http://www.myhost.com/successpage.shtml">
<PARAM NAME="from" VALUE="me@myhost.com">
<PARAM NAME="to" VALUE="you@somehost.com">
<PARAM NAME="subject" VALUE="Servlets are cool">
<PARAM NAME="body" VALUE="Because they can run from ColdFusion">
</SERVLET>

The same servlet can be invoked much more simply from ColdFusion as follows:

<CF_SERVLET CODE=EmailLiteServlet
host="pop.somehost.com"
dest="http://www.myhost.com/successpage.cfm"
from="me@myhost.com"
to="you@somehost.com"
subject="Servlets are cool"
body="Because they can run from ColdFusion">

By default, CF_SERVLET connects to a JRun running on the same machine as ColdFusion. Since JRun's proxy protocol is TCP/IP based, however, you can invoke servlets anywhere you have a JRun, even through a firewall. The following code shows using the JRUNPROXY attribute to access a JRun running on the MyServer.com host:

<CF_SERVLET CODE=MyCoolServlet JRUNPROXY=MyServer.com:8081 Cool="you bet">

Because you're still running inside a ColdFusion page, you can even dynamically choose where to connect to JRun. For example, the user could enter it in a form field:

<CF_SERVLET CODE=RenderNewDo
JRUNPROXY=#Form.JRUNPROXY#
Cool=#Form.HAIRSTYLE#>

The advantages of CF_SERVLET stem from CFML being an easy-to-use, tag-based scripting language and servlets being easy-to-write, powerful plug-ins.

How It Works: CFX_JRUN
CF_SERVLET is a CFML wrapper around CFX_JRUN, a C++-based JRun connector. JRun's out-of-process, connector-based architecture makes it simple to plug into any server environment (Web server or application server). CFX_JRUN hooks JRun into ColdFusion, translating between the CFX API and JRun's proxy protocol. Like JRun's other native connectors, CFX_JRUN has a very small footprint. Once CFX_JRUN is configured into ColdFusion, CF_SERVLET can be dropped into any CFML page.

What About <CF_Anywhere>?
<CF_Anywhere> is a servlet-based CFML engine included in JRun. It translates a CFML subset into Java servlets on the fly, in a manner similar to JSP. Although <CF_Anywhere> also uses the CF_SERVLET tag to invoke servlets, the implementation is completely different from that of ColdFusion. Your custom servlets can thus be invoked equally well from a CFML page, whether that page is executing on ColdFusion or <CF_Anywhere>. The same thing can't be said for other custom CFX plug-ins.

Pricing Information
JRun Pro (Win, Unix, Novell, Mac versions): $595 per processor
JRun Pro Unlimited (Win, Unix, Novell, Mac versions): $1,995 per machine

Conclusion
ColdFusion, CF_SERVLET and JRun together make a great combination: the power of CFML scripting plus the power of Java servlets. If you're a CFML developer considering writing a ColdFusion custom tag, you now have a choice other than CFML, C++ or CFX_J (Java-based version of the C++ CFX API). With CF_SERVLET you can write a Java servlet that can be used by CFML developers or with any Web server or application server. If you're a third-party Java servlet developer writing Web plug-ins for your application, a single servlet could replace your custom ISAPI, NSAPI and CFX plug-ins and broaden your customer base dramatically. If you're a Java servlet developer who wants to tap into the huge market for CF custom tags, CF_SERVLET and JRun are your solution.

About Edwin Smith
Edwin Smith is a principal software engineer at Allaire Corporation and works closely with all aspects of JRun engineering, particularly Java/native integration, system architecture and
performance optimization. Contact at EDSMITH@ALLAIRE.COM

In order to post a comment you need to be registered and logged in.

Register | Sign-in

Reader Feedback: Page 1 of 1

Latest Cloud Developer Stories
Swisscom, the Swiss telecom, is going into the cloud business. Its subsidiary Swisscom IT Services AG has signed up with Red Hat as a Certified Cloud Provider and launched a public cloud Infrastructure-as-a-Service (IaaS) cloud targeting enterprise-class customers primarily in ...
Apache Deltacloud, the Red Hat-contributed ReSTful API that abstracts differences between clouds so services on any cloud can be managed – provided of course there’s a driver – has graduated from the Apache Foundation’s incubator and is now a full-fledged Top-Level Project (TLP)....
In a surprise move on Tuesday, January 10, Oracle wheeled out its Big Data Appliance. That’s the one it said in October would be ready sometime in the first half. Only nobody believed it meant early in the first half. Heck, it’s not even clear anybody thought Oracle could make ...
Rackspace Hosting, the service leader in cloud computing, on Thursday announced its acquisition of SharePoint911, an industry leader in SharePoint consulting, training, and "JumpStart" services within SharePoint. The unification of both companies provides capabilities to deliver ...
CloudLinux, Inc., on Thursday released CafeFS 3, a virtualized file system for shared hosters that cages each customer within its own virtualized file system. CageFS becomes part of CloudLinux OS at no additional charge. CloudLinux OS, the only commercially-supported Linux OS m...
Subscribe to the World's Most Powerful Newsletters
Subscribe to Our Rss Feeds & Get Your SYS-CON News Live!
Click to Add our RSS Feeds to the Service of Your Choice:
Google Reader or Homepage Add to My Yahoo! Subscribe with Bloglines Subscribe in NewsGator Online
myFeedster Add to My AOL Subscribe in Rojo Add 'Hugg' to Newsburst from CNET News.com Kinja Digest View Additional SYS-CON Feeds
Publish Your Article! Please send it to editorial(at)sys-con.com!

Advertise on this site! Contact advertising(at)sys-con.com! 201 802-3021

SYS-CON Featured Whitepapers
ADS BY GOOGLE

Breaking Cloud Computing News
As client demand for engagements increases, Revel Consulting (www.revelconsulting.com), a Kirkland, ...