|By Charlie Arehart||
|May 2, 2002 12:00 AM EDT||
CFMX, the new release of ColdFusion, will allow us to use JSP custom tags within our ColdFusion programs. Some may say, "So what?"
In this article I hope to show you why it's definitely worth looking into this new possibility.
At the time of this writing CFMX, previously known as Neo, is still in beta and the nondisclosure agreement prevents people writing about its features, but one of the few things that have been public knowledge since last year's DevCon is the ability to leverage JSP custom tags.
I've been given the OK by Macromedia (indeed the encouragement) to show this stuff to you. But be aware that what I'm showing is how things work as of beta 3. It's possible that things may change prior to the production release, but again, this functionality has been shown in its current form for nearly a year.
JSP Custom Tags Are Coming
In CFMX it may soon not be unusual to see something like the following in some ColdFusion code:
<cal:calendar month="3" year="2002" />
This is an example of calling a JSP custom tag. This one (which really does exist) will generate an HTML calendar for March 2002, as shown in Figure 1. Pretty nifty. We don't have such a tag in ColdFusion, and it's not that trivial to build calendars, so to be able to generate one so easily with a single tag is powerful.
Some will quickly point out that it's certainly possible that someone could write (and indeed has surely written) a similar sort of ColdFusion custom tag and make it available at the Macromedia Developer's Exchange (at http://devex.macromedia.com/developer/gallery/). Custom tags have been around in ColdFusion for a long time, and they're certainly an underused resource for many.
But this is a JSP custom tag. Don't let that throw you. Does that example above look really all that different to you as a CF developer? Sure, the syntax is a little different from a normal CF custom tag call. Where perhaps we may have used <cf_calendar>, if a tag of that name existed, this one uses <cal:calendar>. That's curious and will be explained in a moment.
But other than that, you don't need to know how the tag works (or how it's built) - all you need to do is call it. And this particular one has many more features than the simple example above demonstrates (you can easily make hyperlinks on given dates, add next/previous month links, and more).
This is a perfect example of a custom tag: something that didn't exist in the language, that someone else created, that we can easily reuse to add functionality to our programs, and that has lots of flexibility.
A New Source for Custom Tags
What's more important about this example is that this Calendar tag came (for free) from a site devoted to JSP custom tags, at http://coldjava.hypermart.net/servlets/. Don't be fooled by the name "coldjava" in the URL. This site really has nothing to do with ColdFusion. It's a total coincidence that the name might suggest a relationship to CF.
It's simply one of many such sites that serve as JSP tag library repositories for JSP developers. I've listed several more later in this article. They're not writing these tags for us, but for the world of JSP developers, and that's a pretty big world, which in many cases is itself only just becoming aware of the possibilities of custom tags.
So what we're talking about here is opening the door to an even larger network of possible sources where we can find reusable custom tags. The fact that they're JSP custom tags is nearly transparent to us.
A Closer Look
Let's look a little closer at the example above. I left out a few pretty important points, such as how to get the custom tag, where to put it, and some other important details.
First, this particular tag is available at http://coldjava.hypermart.net/servlets/caltag.htm. If you can, take a look at that page. As I said, the tag will generate an HTML calendar for you, and the site shows the various syntax alternatives as well as the results of running many of its available variations.
Indeed, in the simplest JSP examples shown there, the use of the custom tag is nearly identical to the way we'd use it in CF. In fact, here's how it might show the example we used below above:
<%@ taglib uri="taglib.tld" prefix="cal" %>
<cal:calendar month="3" year="2002" />
<cal:calendar month="3" year="2002" />
These two lines are indeed an example of a fully functioning JSP page, albeit a very simple one. The only truly foreign thing is that first line, which is a JSP statement. We can't use that specific line of code but will change it to a corresponding CF equivalent. See the sidebar below for more on this.
So, the first line in the preceding sample tells the JSP page where to find the custom tag, meaning where on the server the page should locate the custom tag. We'll change that to a corresponding CF tag in a moment.
JSP Custom Tags vs JSP tags
It's important to clarify that you can not mix JSP and ColdFusion syntax in a single CFMX page. We're talking here about using JSP custom tags, not JSP tags and directives. The use of the JSP custom tag (cal:calendar) is identical to that shown in the simplest JSP code example.
But you may see some examples that show the attribute values for a custom tag being obtained using JSP tags, just as we might use CF variables in the attribute values for a tag. You'd need to change those references before running the code in your CF template. The JSP syntax is often pretty easy to interpret, though not always. Again, we're just talking about translating JSP custom tag documentation into CF.
You may be thinking, "Aha! In CF we don't need to indicate where custom tags are stored. CF figures that out itself." That's true, and it's indeed a nice feature of CF. But, in fact, the CFMX designers have chosen to follow this same logic when using JSP custom tags. To actually run the simple example I showed earlier, I really need to use lines that might look like this:
<CFIMPORT TAGLIB="/WEB-INF/lib/ caltag.jar" PREFIX="cal">
<cal:calendar month="3" year="2002" header="true" />
<cal:calendar month="3" year="2002" header="true" />
That first line looks an awful lot like the JSP code above. It's also a brand-new tag in CFMX. CFIMPORT tells your CF page where on your server to find the JSP custom tag library that you're trying to use. It also names a "prefix" that will describe the means by which you'll refer to tags in this library throughout this page.
Not only does this make our use of tags look more like JSP's use of them, it actually adds some benefit, which in fact will be available to ColdFusion custom tags as well, but that's beyond the scope of this article and would cross the NDA lines to say any more!
Note, too, that I said this CFIMPORT points to the tag library, not the tag itself. That's another difference from CF custom tags. JSP custom tags are generally distributed as libraries of several tags (often called "taglibs", hence the TAGLIB attribute name). It's a more effective way of organizing a set of related custom tags. (Boy, we could sure use a similar capability in organizing collections of related CF custom tags. Wink-wink.)
Just to clarify, the "calendar" after "cal:" is the actual name of the custom tag, or to be more technically accurate, it's the name of the custom tag handler in the taglib. Anyway, for our purposes just know that the documentation for the tag will tell you what to put on the right side of the colon. Don't worry about case sensitivity: CF won't care if the actual tag name is upper- or lowercase. Naturally, you're free to choose your own PREFIX and use that on the left side of the colon; the cases of the PREFIX and the tag name don't have to match..
I said the CFIMPORT tells CF where to find the custom tag library on your server. How do you get it on your server? And where do you place it?
Getting a JSP Custom Tag
If you're interested in leveraging a JSP custom tag library from one of the public sites I refer to here, you simply need to find where on the site it offers a means to download the given custom tag. In the case of the site for the calendar tag offered above, there's a link to the tag's support file at the bottom of the page.
Actually, it offers links to both a ".jar" file and a ".tld" file. The .tld file is another remnant of the JSP specification for custom tags, called the "tag library descriptor" file. It's an XML file. We don't really have to have that or even understand it to leverage the custom tag. We should be able to use TLD's, and the CFMX doc shows it working, but I've had difficulty trying to use it, so I'll chalk it up to beta incompleteness.
All we really need is the .jar file, which is the actual "Java Archive" (get it? "JAR"?) that holds the Java code for the custom tag. Did I scare you just then, talking about Java? Don't worry. You don't need to know Java to use JSP custom tags. Remember, in CF it's just <cal:calendar>, which is really not that foreign.
So you want to click on the link for the .jar file, which should cause your browser to download the file (if not, right-click on the link and choose Save As). If it asks whether to open or save the file, save it. When it offers a location to save it, you'll generally want to put it in a location that's related to where your CFMX application's CF files are stored.
If your CF files are in C:\CFusion MX\wwwroot\ (which is where they might be if you choose to use the built-in CFMX Web server), then you'd also have an underlying C:\CFusionMX\wwwroot\WEB-INF\lib\ directory, and indeed that's where you want to put this .jar file. (Because CFMX is built atop a J2EE platform, this WEB-INF directory structure is a remnant of that, but you'll typically just put your CF files in the wwwroot referred to above or any subdirectory of it.)
Once the file is placed there, at least in my experience with the beta, you need to restart the CFMX server. Perhaps that will change by the time it goes to production.
Pointing to the TagLib
Now, with your .jar file in place, you're ready to use the CFIMPORT. Note, again, that the JSP example shows:
<%@ taglib uri="taglib.tld" prefix="cal" %>
But we're going to change that to:
<CFIMPORT TAGLIB="/WEB-INF/lib/caltag.jar" PREFIX="cal">
There are a couple of differences. Not only do we use a TAGLIB attribute rather than a URI attribute, but I'm also going to recommend (for now) that you change the latter's reference from the .tld to the .jar file you downloaded. (If I learn I've missed something about using TLD files, I'll share it in the comment area of the online version of this article at the SYS-CON Web site.)
Note also that the slashes must be "/" and not "\"; otherwise you'll get a "cannot find file" error. And if you do a copy and paste of a JSP taglib directive, don't forget to remove the "%" at the end of the tag before the ">" or you'll get an "invalid token" error.
One last thing: you may think, "But what if I want to use this JSP custom tag in multiple CF templates? I'll just put that CFIMPORT in my application.cfm". Sorry, you can't do that. At least not as of beta 3. Similarly, you can't even put it in a file and CFINCLUDE it. It's a bummer, but for now you must place that tag wherever you intend to use a custom tag. And there's no default central repository for JSP custom tags to be shared by all apps on a CF server.
Otherwise, that's all there is to it. The steps are:
- Find a suitable custom tag that may seem helpful.
- Download it.
- Place the .jar in the WEB-INF/lib directory.
- Create a CFIMPORT naming that directory and .jar file name and a prefix.
- Create references to the prefix and actual custom tag name in your template.
Finding More Custom Tag Libraries
I mentioned previously that there are several repositories of custom tags, each with dozens or more custom tags. I've found ones for such generally useful things as creating state and country SELECT lists, performing stock quote lookups, and doing credit card number validity checking. Of course, there are CF custom tags and UDFs to do most of these sorts of things as well. But I've also found some for caching page content, SOAP processing, WAP coding, and other things that perhaps CFers may not have thought of yet.
Perhaps the best places to start are some sites set up as "portals" to keep track of available custom tags and taglibs of all sorts (see sidebar below). They're also good places to visit occasionally to see what may be new in the JSP custom tag world.
Among the sites the URLs will point to are a few specialized libraries that may or may not be generically useful for CF applications. Some of the JSP custom tags will indeed be useful only on real JSP pages, but I've found that many of them can be used perfectly well within CFMX
A few taglibs are part of projects to bring standard use of JSP custom tags (and in some cases entire frameworks) to JSP developers. These in-clude things like the Sun JSP Standard Tag Library (JSTL), the Jakarta Taglib project, and the Jakarta Struts project. These offer new frameworks for JSP developers in the form of taglibs, but they may be beyond the interest and reach of CF developers.
Actually, some of the tag libraries offer JSP developers the kind of easy, tag-based control over page flow and database query processing that we've always enjoyed natively in CF. That's kind of interesting to observe, making it seem like CF is the ultimate tag library.
Be careful with that phrase, though. CFMX is not "CF as a JSP tag library." It's really much more than that. Still, some JSPers may indeed see CFMX as a new, easier alternative to JSP itself, even with the many taglibs out there trying to offer a more complete framework.
Finally, a few tag libraries are intended for use with specific J2EE application servers, such as those for JRun, iPlanet, Orion, Gefion, and Oracle Java Web servers. It's likely that few of the tags in these libraries may be generally useful, but they're worth a look. You can't predict when someone in that community may think of something that may be broadly useful.
Admittedly, some of the tags out there in publicly available JSP tag libraries are no more clever than those we already have available in Cold-Fusion custom tags, such as those at the Developer's Exchange. But you never know. It's like finding a new directory in the Developer's Exchange, but it's a much bigger world of developers out there building JSP custom tags.
At each of these sites you'll generally find help on how to use the tags. Sometimes the documentation for using a JSP custom tag may show it using JSP syntax, but it will often be readable enough for CF programmers. More to the point, perhaps more CF people will start sharing their discoveries of useful JSP custom tag libraries, including documentation of how to use them within CF. Indeed, what we really need is a repository for people to share their observations of useful JSP custom tags. I'll start one at www.systemanage.com/taglibs/.
As far as learning more about using JSP custom tags within CFMX, you should look to the CFMX documentation (and release notes, new features guides, etc.) that will be made public when the product goes into production.
As for learning more about the general subject of JSP custom tags, several books cover it from a Java or JSP perspective. They can be helpful, but mostly for those creating JSP custom tags or using them within JSPs. I'll point you to a couple. There are certainly others. Perhaps the most complete book on the subject is Mastering JSP Custom Tags and Tag Libraries, by James Goodwill. It's just come out.
There are chapters in other books, as well as several articles and tutorials of the same sort online. Perhaps the best place to point you is a repository listing many of them at www.jspinsider.com/tutorials/jsp/taglibraries.view.
When All's Said and Done...
Now you have it: what JSP custom tags are, how and why you might use them within CF, and where to find them and more information about them. Should you be interested in such possibilities? I think so. And, again, you definitely don't need any Java or JSP experience to benefit from them. They can simply provide some useful, reusable functionality that you can leverage in your CF (or JSP) pages. There's quite a bit more that we could discuss about them, but this should be enough to get you started.
|charles arehart 09/08/02 04:56:00 AM EDT|
|Charles Arehart 08/07/02 01:08:00 PM EDT|
Folks, I'm sad to have to report that I've now confirmed that the use of CFIMPORT to call JSP custom tags does NOT work in the Pro edition of CF. It will work in Enterprise, as well as the Trial (which is enterprise) and the Developer Edition (which the Trial becomes after 30 days, reverting to a single-user version).
|charles arehart 05/22/02 04:58:00 PM EDT|
Folks, here's another update of info I've learned since the article. First, you don't HAVE to place your jar file in the web-inf\lib directory as I (and the docs) had stated. I've found that you can indeed put them in the same directory as your CF template that's calling them, and then just say
That's useful if you work in an environment where you may find th web-inf directory locked down for any reason.
Also, in the preview release candidate, you can now refer to TLD files in the CFIMPORT, and again they can be located either in web-inf\ or in the same dir as your code.
Of course, when I say you can put these in the same dir as your code, I also mean you can put them in some other dir in the web root and use a relative reference to point to it.
|charles arehart 05/22/02 04:54:00 PM EDT|
Folks, just wanted to add some info for you. If you try out these tags as I have offered in the article, you may find that you get the error:
The type for attribute xxx of tag yyy could not be determined.
where xxx is the attribute you're using and yyy is the tag whose attributes it's complaining about.
Though I didn't mention that error specifically, I did say that it was my experience that you needed to restart the server upon placing a new tag into the web-inf\lib directory.
This error is what you'll see if you don't.
SYS-CON Events announced today that CollabNet, a global leader in enterprise software development, release automation and DevOps solutions, will be a Bronze Sponsor of SYS-CON's 20th International Cloud Expo®, taking place from June 6-8, 2017, at the Javits Center in New York City, NY. CollabNet offers a broad range of solutions with the mission of helping modern organizations deliver quality software at speed. The company’s latest innovation, the DevOps Lifecycle Manager (DLM), supports Value S...
Apr. 27, 2017 08:00 PM EDT Reads: 1,111
The Internet of Things is clearly many things: data collection and analytics, wearables, Smart Grids and Smart Cities, the Industrial Internet, and more. Cool platforms like Arduino, Raspberry Pi, Intel's Galileo and Edison, and a diverse world of sensors are making the IoT a great toy box for developers in all these areas. In this Power Panel at @ThingsExpo, moderated by Conference Chair Roger Strukhoff, panelists discussed what things are the most important, which will have the most profound e...
Apr. 27, 2017 07:45 PM EDT Reads: 2,297
Multiple data types are pouring into IoT deployments. Data is coming in small packages as well as enormous files and data streams of many sizes. Widespread use of mobile devices adds to the total. In this power panel at @ThingsExpo, moderated by Conference Chair Roger Strukhoff, panelists will look at the tools and environments that are being put to use in IoT deployments, as well as the team skills a modern enterprise IT shop needs to keep things running, get a handle on all this data, and deli...
Apr. 27, 2017 07:30 PM EDT Reads: 2,465
The explosion of new web/cloud/IoT-based applications and the data they generate are transforming our world right before our eyes. In this rush to adopt these new technologies, organizations are often ignoring fundamental questions concerning who owns the data and failing to ask for permission to conduct invasive surveillance of their customers. Organizations that are not transparent about how their systems gather data telemetry without offering shared data ownership risk product rejection, regu...
Apr. 27, 2017 07:15 PM EDT Reads: 1,616
SYS-CON Events announced today that Grape Up will exhibit at SYS-CON's 21st International Cloud Expo®, which will take place on Oct. 31 – Nov 2, 2017, at the Santa Clara Convention Center in Santa Clara, CA. Grape Up is a software company specializing in cloud native application development and professional services related to Cloud Foundry PaaS. With five expert teams that operate in various sectors of the market across the U.S. and Europe, Grape Up works with a variety of customers from emergi...
Apr. 27, 2017 06:45 PM EDT Reads: 2,204
The age of Digital Disruption is evolving into the next era – Digital Cohesion, an age in which applications securely self-assemble and deliver predictive services that continuously adapt to user behavior. Information from devices, sensors and applications around us will drive services seamlessly across mobile and fixed devices/infrastructure. This evolution is happening now in software defined services and secure networking. Four key drivers – Performance, Economics, Interoperability and Trust ...
Apr. 27, 2017 06:45 PM EDT Reads: 731
@ThingsExpo has been named the Most Influential ‘Smart Cities - IIoT' Account and @BigDataExpo has been named fourteenth by Right Relevance (RR), which provides curated information and intelligence on approximately 50,000 topics. In addition, Right Relevance provides an Insights offering that combines the above Topics and Influencers information with real time conversations to provide actionable intelligence with visualizations to enable decision making. The Insights service is applicable to eve...
Apr. 27, 2017 06:30 PM EDT Reads: 2,817
DevOps is often described as a combination of technology and culture. Without both, DevOps isn't complete. However, applying the culture to outdated technology is a recipe for disaster; as response times grow and connections between teams are delayed by technology, the culture will die. A Nutanix Enterprise Cloud has many benefits that provide the needed base for a true DevOps paradigm.
Apr. 27, 2017 06:00 PM EDT Reads: 1,033
Cybersecurity is a critical component of software development in many industries including medical devices. However, code is not always written to be robust or secure from the unknown or the unexpected. This gap can make medical devices susceptible to cybersecurity attacks ranging from compromised personal health information to life-sustaining treatment. In his session at @ThingsExpo, Clark Fortney, Software Engineer at Battelle, will discuss how programming oversight using key methods can incre...
Apr. 27, 2017 05:30 PM EDT Reads: 3,960
Most technology leaders, contemporary and from the hardware era, are reshaping their businesses to do software in the hope of capturing value in IoT. Although IoT is relatively new in the market, it has already gone through many promotional terms such as IoE, IoX, SDX, Edge/Fog, Mist Compute, etc. Ultimately, irrespective of the name, it is about deriving value from independent software assets participating in an ecosystem as one comprehensive solution.
Apr. 27, 2017 03:45 PM EDT Reads: 561
The 20th International Cloud Expo has announced that its Call for Papers is open. Cloud Expo, to be held June 6-8, 2017, at the Javits Center in New York City, brings together Cloud Computing, Big Data, Internet of Things, DevOps, Containers, Microservices and WebRTC to one location. With cloud computing driving a higher percentage of enterprise IT budgets every year, it becomes increasingly important to plant your flag in this fast-expanding business opportunity. Submit your speaking proposal ...
Apr. 27, 2017 01:45 PM EDT Reads: 1,302
SYS-CON Events announced today that Juniper Networks (NYSE: JNPR), an industry leader in automated, scalable and secure networks, will exhibit at SYS-CON's 20th International Cloud Expo®, which will take place on June 6-8, 2017, at the Javits Center in New York City, NY. Juniper Networks challenges the status quo with products, solutions and services that transform the economics of networking. The company co-innovates with customers and partners to deliver automated, scalable and secure network...
Apr. 27, 2017 01:15 PM EDT Reads: 1,464
New competitors, disruptive technologies, and growing expectations are pushing every business to both adopt and deliver new digital services. This ‘Digital Transformation’ demands rapid delivery and continuous iteration of new competitive services via multiple channels, which in turn demands new service delivery techniques – including DevOps. In this power panel at @DevOpsSummit 20th Cloud Expo, moderated by DevOps Conference Co-Chair Andi Mann, panelists will examine how DevOps helps to meet th...
Apr. 27, 2017 01:15 PM EDT Reads: 1,592
SYS-CON Events announced today that Hitachi, the leading provider the Internet of Things and Digital Transformation, will exhibit at SYS-CON's 20th International Cloud Expo®, which will take place on June 6-8, 2017, at the Javits Center in New York City, NY. Hitachi Data Systems, a wholly owned subsidiary of Hitachi, Ltd., offers an integrated portfolio of services and solutions that enable digital transformation through enhanced data management, governance, mobility and analytics. We help globa...
Apr. 27, 2017 12:45 PM EDT Reads: 1,306
SYS-CON Events announced today that T-Mobile will exhibit at SYS-CON's 20th International Cloud Expo®, which will take place on June 6-8, 2017, at the Javits Center in New York City, NY. As America's Un-carrier, T-Mobile US, Inc., is redefining the way consumers and businesses buy wireless services through leading product and service innovation. The Company's advanced nationwide 4G LTE network delivers outstanding wireless experiences to 67.4 million customers who are unwilling to compromise on ...
Apr. 27, 2017 12:30 PM EDT Reads: 1,232
Five years ago development was seen as a dead-end career, now it’s anything but – with an explosion in mobile and IoT initiatives increasing the demand for skilled engineers. But apart from having a ready supply of great coders, what constitutes true ‘DevOps Royalty’? It’ll be the ability to craft resilient architectures, supportability, security everywhere across the software lifecycle. In his keynote at @DevOpsSummit at 20th Cloud Expo, Jeffrey Scheaffer, GM and SVP, Continuous Delivery Busine...
Apr. 27, 2017 12:30 PM EDT Reads: 1,061
20th Cloud Expo, taking place June 6-8, 2017, at the Javits Center in New York City, NY, will feature technical sessions from a rock star conference faculty and the leading industry players in the world. Cloud computing is now being embraced by a majority of enterprises of all sizes. Yesterday's debate about public vs. private has transformed into the reality of hybrid cloud: a recent survey shows that 74% of enterprises have a hybrid cloud strategy.
Apr. 27, 2017 12:15 PM EDT Reads: 3,154
With major technology companies and startups seriously embracing IoT strategies, now is the perfect time to attend @ThingsExpo 2016 in New York. Learn what is going on, contribute to the discussions, and ensure that your enterprise is as "IoT-Ready" as it can be! Internet of @ThingsExpo, taking place June 6-8, 2017, at the Javits Center in New York City, New York, is co-located with 20th Cloud Expo and will feature technical sessions from a rock star conference faculty and the leading industry p...
Apr. 27, 2017 12:15 PM EDT Reads: 1,232
With major technology companies and startups seriously embracing Cloud strategies, now is the perfect time to attend @CloudExpo | @ThingsExpo, June 6-8, 2017, at the Javits Center in New York City, NY and October 31 - November 2, 2017, Santa Clara Convention Center, CA. Learn what is going on, contribute to the discussions, and ensure that your enterprise is on the right path to Digital Transformation.
Apr. 27, 2017 12:00 PM EDT Reads: 1,340
SYS-CON Events announced today that SoftLayer, an IBM Company, has been named “Gold Sponsor” of SYS-CON's 18th Cloud Expo, which will take place on June 7-9, 2016, at the Javits Center in New York, New York. SoftLayer, an IBM Company, provides cloud infrastructure as a service from a growing number of data centers and network points of presence around the world. SoftLayer’s customers range from Web startups to global enterprises.
Apr. 27, 2017 10:45 AM EDT Reads: 2,211