|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.
"Once customers get a year into their IoT deployments, they start to realize that they may have been shortsighted in the ways they built out their deployment and the key thing I see a lot of people looking at is - how can I take equipment data, pull it back in an IoT solution and show it in a dashboard," stated Dave McCarthy, Director of Products at Bsquare Corporation, in this SYS-CON.tv interview at @ThingsExpo, held November 1-3, 2016, at the Santa Clara Convention Center in Santa Clara, CA.
Dec. 3, 2016 11:00 PM EST Reads: 949
The cloud promises new levels of agility and cost-savings for Big Data, data warehousing and analytics. But it’s challenging to understand all the options – from IaaS and PaaS to newer services like HaaS (Hadoop as a Service) and BDaaS (Big Data as a Service). In her session at @BigDataExpo at @ThingsExpo, Hannah Smalltree, a director at Cazena, provided an educational overview of emerging “as-a-service” options for Big Data in the cloud. This is critical background for IT and data professionals...
Dec. 3, 2016 11:00 PM EST Reads: 4,131
Fact is, enterprises have significant legacy voice infrastructure that’s costly to replace with pure IP solutions. How can we bring this analog infrastructure into our shiny new cloud applications? There are proven methods to bind both legacy voice applications and traditional PSTN audio into cloud-based applications and services at a carrier scale. Some of the most successful implementations leverage WebRTC, WebSockets, SIP and other open source technologies. In his session at @ThingsExpo, Da...
Dec. 3, 2016 09:30 PM EST Reads: 1,599
As data explodes in quantity, importance and from new sources, the need for managing and protecting data residing across physical, virtual, and cloud environments grow with it. Managing data includes protecting it, indexing and classifying it for true, long-term management, compliance and E-Discovery. Commvault can ensure this with a single pane of glass solution – whether in a private cloud, a Service Provider delivered public cloud or a hybrid cloud environment – across the heterogeneous enter...
Dec. 3, 2016 06:15 PM EST Reads: 1,513
"IoT is going to be a huge industry with a lot of value for end users, for industries, for consumers, for manufacturers. How can we use cloud to effectively manage IoT applications," stated Ian Khan, Innovation & Marketing Manager at Solgeniakhela, in this SYS-CON.tv interview at @ThingsExpo, held November 3-5, 2015, at the Santa Clara Convention Center in Santa Clara, CA.
Dec. 3, 2016 05:30 PM EST Reads: 4,045
Today we can collect lots and lots of performance data. We build beautiful dashboards and even have fancy query languages to access and transform the data. Still performance data is a secret language only a couple of people understand. The more business becomes digital the more stakeholders are interested in this data including how it relates to business. Some of these people have never used a monitoring tool before. They have a question on their mind like “How is my application doing” but no id...
Dec. 3, 2016 05:15 PM EST Reads: 2,138
@GonzalezCarmen has been ranked the Number One Influencer and @ThingsExpo has been named the Number One Brand in the “M2M 2016: Top 100 Influencers and Brands” by Onalytica. Onalytica analyzed tweets over the last 6 months mentioning the keywords M2M OR “Machine to Machine.” They then identified the top 100 most influential brands and individuals leading the discussion on Twitter.
Dec. 3, 2016 05:15 PM EST Reads: 2,001
Information technology is an industry that has always experienced change, and the dramatic change sweeping across the industry today could not be truthfully described as the first time we've seen such widespread change impacting customer investments. However, the rate of the change, and the potential outcomes from today's digital transformation has the distinct potential to separate the industry into two camps: Organizations that see the change coming, embrace it, and successful leverage it; and...
Dec. 3, 2016 03:15 PM EST Reads: 3,225
The Internet of Things (IoT) promises to simplify and streamline our lives by automating routine tasks that distract us from our goals. This promise is based on the ubiquitous deployment of smart, connected devices that link everything from industrial control systems to automobiles to refrigerators. Unfortunately, comparatively few of the devices currently deployed have been developed with an eye toward security, and as the DDoS attacks of late October 2016 have demonstrated, this oversight can ...
Dec. 3, 2016 02:45 PM EST Reads: 715
Extracting business value from Internet of Things (IoT) data doesn’t happen overnight. There are several requirements that must be satisfied, including IoT device enablement, data analysis, real-time detection of complex events and automated orchestration of actions. Unfortunately, too many companies fall short in achieving their business goals by implementing incomplete solutions or not focusing on tangible use cases. In his general session at @ThingsExpo, Dave McCarthy, Director of Products...
Dec. 3, 2016 02:45 PM EST Reads: 529
Machine Learning helps make complex systems more efficient. By applying advanced Machine Learning techniques such as Cognitive Fingerprinting, wind project operators can utilize these tools to learn from collected data, detect regular patterns, and optimize their own operations. In his session at 18th Cloud Expo, Stuart Gillen, Director of Business Development at SparkCognition, discussed how research has demonstrated the value of Machine Learning in delivering next generation analytics to impr...
Dec. 3, 2016 02:15 PM EST Reads: 6,957
More and more brands have jumped on the IoT bandwagon. We have an excess of wearables – activity trackers, smartwatches, smart glasses and sneakers, and more that track seemingly endless datapoints. However, most consumers have no idea what “IoT” means. Creating more wearables that track data shouldn't be the aim of brands; delivering meaningful, tangible relevance to their users should be. We're in a period in which the IoT pendulum is still swinging. Initially, it swung toward "smart for smar...
Dec. 3, 2016 02:00 PM EST Reads: 483
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.
Dec. 3, 2016 01:30 PM EST Reads: 2,131
Businesses and business units of all sizes can benefit from cloud computing, but many don't want the cost, performance and security concerns of public cloud nor the complexity of building their own private clouds. Today, some cloud vendors are using artificial intelligence (AI) to simplify cloud deployment and management. In his session at 20th Cloud Expo, Ajay Gulati, Co-founder and CEO of ZeroStack, will discuss how AI can simplify cloud operations. He will cover the following topics: why clou...
Dec. 3, 2016 01:15 PM EST Reads: 634
Internet of @ThingsExpo, taking place June 6-8, 2017 at the Javits Center in New York City, New York, is co-located with the 20th International Cloud Expo and will feature technical sessions from a rock star conference faculty and the leading industry players in the world. @ThingsExpo New York Call for Papers is now open.
Dec. 3, 2016 01:00 PM EST Reads: 1,876
"ReadyTalk is an audio and web video conferencing provider. We've really come to embrace WebRTC as the platform for our future of technology," explained Dan Cunningham, CTO of ReadyTalk, in this SYS-CON.tv interview at WebRTC Summit at 19th Cloud Expo, held November 1-3, 2016, at the Santa Clara Convention Center in Santa Clara, CA.
Dec. 3, 2016 01:00 PM EST Reads: 331
Successful digital transformation requires new organizational competencies and capabilities. Research tells us that the biggest impediment to successful transformation is human; consequently, the biggest enabler is a properly skilled and empowered workforce. In the digital age, new individual and collective competencies are required. In his session at 19th Cloud Expo, Bob Newhouse, CEO and founder of Agilitiv, drew together recent research and lessons learned from emerging and established compa...
Dec. 3, 2016 12:45 PM EST Reads: 741
Data is the fuel that drives the machine learning algorithmic engines and ultimately provides the business value. In his session at Cloud Expo, Ed Featherston, a director and senior enterprise architect at Collaborative Consulting, discussed the key considerations around quality, volume, timeliness, and pedigree that must be dealt with in order to properly fuel that engine.
Dec. 3, 2016 12:45 PM EST Reads: 1,956
Everyone knows that truly innovative companies learn as they go along, pushing boundaries in response to market changes and demands. What's more of a mystery is how to balance innovation on a fresh platform built from scratch with the legacy tech stack, product suite and customers that continue to serve as the business' foundation. In his General Session at 19th Cloud Expo, Michael Chambliss, Head of Engineering at ReadyTalk, discussed why and how ReadyTalk diverted from healthy revenue and mor...
Dec. 3, 2016 12:15 PM EST Reads: 1,512
We are always online. We access our data, our finances, work, and various services on the Internet. But we live in a congested world of information in which the roads were built two decades ago. The quest for better, faster Internet routing has been around for a decade, but nobody solved this problem. We’ve seen band-aid approaches like CDNs that attack a niche's slice of static content part of the Internet, but that’s it. It does not address the dynamic services-based Internet of today. It does...
Dec. 3, 2016 11:30 AM EST Reads: 857