|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.
"We work in the area of Big Data analytics and Big Data analytics is a very crowded space - you have Hadoop, ETL, warehousing, visualization and there's a lot of effort trying to get these tools to talk to each other," explained Mukund Deshpande, head of the Analytics practice at Accelerite, in this SYS-CON.tv interview at 18th Cloud Expo, held June 7-9, 2016, at the Javits Center in New York City, NY.
Jul. 2, 2016 01:30 AM EDT Reads: 847
Cloud Expo, Inc. has announced today that Andi Mann returns to 'DevOps at Cloud Expo 2016' as Conference Chair The @DevOpsSummit at Cloud Expo will take place on November 1-3, 2016, at the Santa Clara Convention Center in Santa Clara, CA. "DevOps is set to be one of the most profound disruptions to hit IT in decades," said Andi Mann. "It is a natural extension of cloud computing, and I have seen both firsthand and in independent research the fantastic results DevOps delivers. So I am excited t...
Jul. 2, 2016 01:00 AM EDT Reads: 764
Basho Technologies has announced the latest release of Basho Riak TS, version 1.3. Riak TS is an enterprise-grade NoSQL database optimized for Internet of Things (IoT). The open source version enables developers to download the software for free and use it in production as well as make contributions to the code and develop applications around Riak TS. Enhancements to Riak TS make it quick, easy and cost-effective to spin up an instance to test new ideas and build IoT applications. In addition to...
Jul. 1, 2016 08:30 PM EDT Reads: 807
IoT is rapidly changing the way enterprises are using data to improve business decision-making. In order to derive business value, organizations must unlock insights from the data gathered and then act on these. In their session at @ThingsExpo, Eric Hoffman, Vice President at EastBanc Technologies, and Peter Shashkin, Head of Development Department at EastBanc Technologies, discussed how one organization leveraged IoT, cloud technology and data analysis to improve customer experiences and effi...
Jul. 1, 2016 06:30 PM EDT Reads: 785
Internet of @ThingsExpo has announced today that Chris Matthieu has been named tech chair of Internet of @ThingsExpo 2016 Silicon Valley. The 6thInternet of @ThingsExpo will take place on November 1–3, 2016, at the Santa Clara Convention Center in Santa Clara, CA.
Jul. 1, 2016 06:00 PM EDT Reads: 551
Presidio has received the 2015 EMC Partner Services Quality Award from EMC Corporation for achieving outstanding service excellence and customer satisfaction as measured by the EMC Partner Services Quality (PSQ) program. Presidio was also honored as the 2015 EMC Americas Marketing Excellence Partner of the Year and 2015 Mid-Market East Partner of the Year. The EMC PSQ program is a project-specific survey program designed for partners with Service Partner designations to solicit customer feedbac...
Jul. 1, 2016 05:30 PM EDT Reads: 798
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 profession...
Jul. 1, 2016 05:15 PM EDT Reads: 659
"There's a growing demand from users for things to be faster. When you think about all the transactions or interactions users will have with your product and everything that is between those transactions and interactions - what drives us at Catchpoint Systems is the idea to measure that and to analyze it," explained Leo Vasiliou, Director of Web Performance Engineering at Catchpoint Systems, in this SYS-CON.tv interview at 18th Cloud Expo, held June 7-9, 2016, at the Javits Center in New York Ci...
Jul. 1, 2016 04:15 PM EDT Reads: 270
Ask someone to architect an Internet of Things (IoT) solution and you are guaranteed to see a reference to the cloud. This would lead you to believe that IoT requires the cloud to exist. However, there are many IoT use cases where the cloud is not feasible or desirable. In his session at @ThingsExpo, Dave McCarthy, Director of Products at Bsquare Corporation, will discuss the strategies that exist to extend intelligence directly to IoT devices and sensors, freeing them from the constraints of ...
Jul. 1, 2016 03:15 PM EDT Reads: 340
Connected devices and the industrial internet are growing exponentially every year with Cisco expecting 50 billion devices to be in operation by 2020. In this period of growth, location-based insights are becoming invaluable to many businesses as they adopt new connected technologies. Knowing when and where these devices connect from is critical for a number of scenarios in supply chain management, disaster management, emergency response, M2M, location marketing and more. In his session at @Th...
Jul. 1, 2016 02:00 PM EDT Reads: 1,437
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...
Jul. 1, 2016 01:15 PM EDT Reads: 357
There are several IoTs: the Industrial Internet, Consumer Wearables, Wearables and Healthcare, Supply Chains, and the movement toward Smart Grids, Cities, Regions, and Nations. There are competing communications standards every step of the way, a bewildering array of sensors and devices, and an entire world of competing data analytics platforms. To some this appears to be chaos. In this power panel at @ThingsExpo, moderated by Conference Chair Roger Strukhoff, Bradley Holt, Developer Advocate a...
Jul. 1, 2016 01:00 PM EDT Reads: 1,053
The Internet of Things will challenge the status quo of how IT and development organizations operate. Or will it? Certainly the fog layer of IoT requires special insights about data ontology, security and transactional integrity. But the developmental challenges are the same: People, Process and Platform and how we integrate our thinking to solve complicated problems. In his session at 19th Cloud Expo, Craig Sproule, CEO of Metavine, will demonstrate how to move beyond today's coding paradigm ...
Jul. 1, 2016 01:00 PM EDT Reads: 709
Apixio Inc. has raised $19.3 million in Series D venture capital funding led by SSM Partners with participation from First Analysis, Bain Capital Ventures and Apixio’s largest angel investor. Apixio will dedicate the proceeds toward advancing and scaling products powered by its cognitive computing platform, further enabling insights for optimal patient care. The Series D funding comes as Apixio experiences strong momentum and increasing demand for its HCC Profiler solution, which mines unstruc...
Jul. 1, 2016 12:30 PM EDT Reads: 694
SYS-CON Events has announced today that Roger Strukhoff has been named conference chair of Cloud Expo and @ThingsExpo 2016 Silicon Valley. The 19th Cloud Expo and 6th @ThingsExpo will take place on November 1-3, 2016, at the Santa Clara Convention Center in Santa Clara, CA. "The Internet of Things brings trillions of dollars of opportunity to developers and enterprise IT, no matter how you measure it," stated Roger Strukhoff. "More importantly, it leverages the power of devices and the Interne...
Jul. 1, 2016 12:00 PM EDT Reads: 664
In addition to all the benefits, IoT is also bringing new kind of customer experience challenges - cars that unlock themselves, thermostats turning houses into saunas and baby video monitors broadcasting over the internet. This list can only increase because while IoT services should be intuitive and simple to use, the delivery ecosystem is a myriad of potential problems as IoT explodes complexity. So finding a performance issue is like finding the proverbial needle in the haystack.
Jul. 1, 2016 10:45 AM EDT Reads: 588
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 imp...
Jul. 1, 2016 10:30 AM EDT Reads: 1,118
Whether your IoT service is connecting cars, homes, appliances, wearable, cameras or other devices, one question hangs in the balance – how do you actually make money from this service? The ability to turn your IoT service into profit requires the ability to create a monetization strategy that is flexible, scalable and working for you in real-time. It must be a transparent, smoothly implemented strategy that all stakeholders – from customers to the board – will be able to understand and comprehe...
Jul. 1, 2016 10:00 AM EDT Reads: 542
The cloud market growth today is largely in public clouds. While there is a lot of spend in IT departments in virtualization, these aren’t yet translating into a true “cloud” experience within the enterprise. What is stopping the growth of the “private cloud” market? In his general session at 18th Cloud Expo, Nara Rajagopalan, CEO of Accelerite, explored the challenges in deploying, managing, and getting adoption for a private cloud within an enterprise. What are the key differences between wh...
Jul. 1, 2016 09:30 AM EDT Reads: 1,217
The IoT is changing the way enterprises conduct business. In his session at @ThingsExpo, Eric Hoffman, Vice President at EastBanc Technologies, discussed how businesses can gain an edge over competitors by empowering consumers to take control through IoT. He cited examples such as a Washington, D.C.-based sports club that leveraged IoT and the cloud to develop a comprehensive booking system. He also highlighted how IoT can revitalize and restore outdated business models, making them profitable ...
Jul. 1, 2016 09:00 AM EDT Reads: 713