|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.
The Internet of Everything (IoE) brings together people, process, data and things to make networked connections more relevant and valuable than ever before – transforming information into knowledge and knowledge into wisdom. IoE creates new capabilities, richer experiences, and unprecedented opportunities to improve business and government operations, decision making and mission support capabilities.
Jul. 30, 2015 09:00 AM EDT Reads: 248
In his keynote at 16th Cloud Expo, Rodney Rogers, CEO of Virtustream, discussed the evolution of the company from inception to its recent acquisition by EMC – including personal insights, lessons learned (and some WTF moments) along the way. Learn how Virtustream’s unique approach of combining the economics and elasticity of the consumer cloud model with proper performance, application automation and security into a platform became a breakout success with enterprise customers and a natural fit for the EMC Federation.
Jul. 30, 2015 09:00 AM EDT Reads: 2,146
The Internet of Things is not only adding billions of sensors and billions of terabytes to the Internet. It is also forcing a fundamental change in the way we envision Information Technology. For the first time, more data is being created by devices at the edge of the Internet rather than from centralized systems. What does this mean for today's IT professional? In this Power Panel at @ThingsExpo, moderated by Conference Chair Roger Strukhoff, panelists addressed this very serious issue of profound change in the industry.
Jul. 29, 2015 03:00 PM EDT Reads: 1,259
Discussions about cloud computing are evolving into discussions about enterprise IT in general. As enterprises increasingly migrate toward their own unique clouds, new issues such as the use of containers and microservices emerge to keep things interesting. In this Power Panel at 16th Cloud Expo, moderated by Conference Chair Roger Strukhoff, panelists addressed the state of cloud computing today, and what enterprise IT professionals need to know about how the latest topics and trends affect their organization.
Jul. 29, 2015 02:00 PM EDT Reads: 1,176
SYS-CON Events announced today that HPM Networks will exhibit at the 17th International Cloud Expo®, which will take place on November 3–5, 2015, at the Santa Clara Convention Center in Santa Clara, CA. For 20 years, HPM Networks has been integrating technology solutions that solve complex business challenges. HPM Networks has designed solutions for both SMB and enterprise customers throughout the San Francisco Bay Area.
Jul. 29, 2015 01:45 PM EDT Reads: 431
For IoT to grow as quickly as analyst firms’ project, a lot is going to fall on developers to quickly bring applications to market. But the lack of a standard development platform threatens to slow growth and make application development more time consuming and costly, much like we’ve seen in the mobile space. In his session at @ThingsExpo, Mike Weiner, Product Manager of the Omega DevCloud with KORE Telematics Inc., discussed the evolving requirements for developers as IoT matures and conducted a live demonstration of how quickly application development can happen when the need to comply wit...
Jul. 29, 2015 07:30 AM EDT Reads: 281
Explosive growth in connected devices. Enormous amounts of data for collection and analysis. Critical use of data for split-second decision making and actionable information. All three are factors in making the Internet of Things a reality. Yet, any one factor would have an IT organization pondering its infrastructure strategy. How should your organization enhance its IT framework to enable an Internet of Things implementation? In his session at @ThingsExpo, James Kirkland, Red Hat's Chief Architect for the Internet of Things and Intelligent Systems, described how to revolutionize your archit...
Jul. 28, 2015 06:30 PM EDT Reads: 1,378
It is one thing to build single industrial IoT applications, but what will it take to build the Smart Cities and truly society-changing applications of the future? The technology won’t be the problem, it will be the number of parties that need to work together and be aligned in their motivation to succeed. In his session at @ThingsExpo, Jason Mondanaro, Director, Product Management at Metanga, discussed how you can plan to cooperate, partner, and form lasting all-star teams to change the world and it starts with business models and monetization strategies.
Jul. 28, 2015 04:30 PM EDT Reads: 1,757
Converging digital disruptions is creating a major sea change - Cisco calls this the Internet of Everything (IoE). IoE is the network connection of People, Process, Data and Things, fueled by Cloud, Mobile, Social, Analytics and Security, and it represents a $19Trillion value-at-stake over the next 10 years. In her keynote at @ThingsExpo, Manjula Talreja, VP of Cisco Consulting Services, discussed IoE and the enormous opportunities it provides to public and private firms alike. She will share what businesses must do to thrive in the IoE economy, citing examples from several industry sectors.
Jul. 28, 2015 11:00 AM EDT Reads: 2,036
Growth hacking is common for startups to make unheard-of progress in building their business. Career Hacks can help Geek Girls and those who support them (yes, that's you too, Dad!) to excel in this typically male-dominated world. Get ready to learn the facts: Is there a bias against women in the tech / developer communities? Why are women 50% of the workforce, but hold only 24% of the STEM or IT positions? Some beginnings of what to do about it! In her Opening Keynote at 16th Cloud Expo, Sandy Carter, IBM General Manager Cloud Ecosystem and Developers, and a Social Business Evangelist, d...
Jul. 27, 2015 09:00 PM EDT Reads: 2,042
There will be 150 billion connected devices by 2020. New digital businesses have already disrupted value chains across every industry. APIs are at the center of the digital business. You need to understand what assets you have that can be exposed digitally, what their digital value chain is, and how to create an effective business model around that value chain to compete in this economy. No enterprise can be complacent and not engage in the digital economy. Learn how to be the disruptor and not the disruptee.
Jul. 27, 2015 10:00 AM EDT Reads: 2,023
Akana has released Envision, an enhanced API analytics platform that helps enterprises mine critical insights across their digital eco-systems, understand their customers and partners and offer value-added personalized services. “In today’s digital economy, data-driven insights are proving to be a key differentiator for businesses. Understanding the data that is being tunneled through their APIs and how it can be used to optimize their business and operations is of paramount importance,” said Alistair Farquharson, CTO of Akana.
Jul. 27, 2015 09:00 AM EDT Reads: 315
Business as usual for IT is evolving into a "Make or Buy" decision on a service-by-service conversation with input from the LOBs. How does your organization move forward with cloud? In his general session at 16th Cloud Expo, Paul Maravei, Regional Sales Manager, Hybrid Cloud and Managed Services at Cisco, discusses how Cisco and its partners offer a market-leading portfolio and ecosystem of cloud infrastructure and application services that allow you to uniquely and securely combine cloud business applications and services across multiple cloud delivery models.
Jul. 27, 2015 08:00 AM EDT Reads: 1,898
The enterprise market will drive IoT device adoption over the next five years. In his session at @ThingsExpo, John Greenough, an analyst at BI Intelligence, division of Business Insider, analyzed how companies will adopt IoT products and the associated cost of adopting those products. John Greenough is the lead analyst covering the Internet of Things for BI Intelligence- Business Insider’s paid research service. Numerous IoT companies have cited his analysis of the IoT. Prior to joining BI Intelligence, he worked analyzing bank technology for Corporate Insight and The Clearing House Payment...
Jul. 26, 2015 09:00 PM EDT Reads: 1,568
"Optimal Design is a technology integration and product development firm that specializes in connecting devices to the cloud," stated Joe Wascow, Co-Founder & CMO of Optimal Design, in this SYS-CON.tv interview at @ThingsExpo, held June 9-11, 2015, at the Javits Center in New York City.
Jul. 25, 2015 02:00 PM EDT Reads: 382
SYS-CON Events announced today that CommVault has been named “Bronze Sponsor” of SYS-CON's 17th International Cloud Expo®, which will take place on November 3–5, 2015, at the Santa Clara Convention Center in Santa Clara, CA. A singular vision – a belief in a better way to address current and future data management needs – guides CommVault in the development of Singular Information Management® solutions for high-performance data protection, universal availability and simplified management of data on complex storage networks. CommVault's exclusive single-platform architecture gives companies unp...
Jul. 25, 2015 01:00 PM EDT Reads: 1,949
Electric Cloud and Arynga have announced a product integration partnership that will bring Continuous Delivery solutions to the automotive Internet-of-Things (IoT) market. The joint solution will help automotive manufacturers, OEMs and system integrators adopt DevOps automation and Continuous Delivery practices that reduce software build and release cycle times within the complex and specific parameters of embedded and IoT software systems.
Jul. 25, 2015 12:15 PM EDT Reads: 452
"ciqada is a combined platform of hardware modules and server products that lets people take their existing devices or new devices and lets them be accessible over the Internet for their users," noted Geoff Engelstein of ciqada, a division of Mars International, in this SYS-CON.tv interview at @ThingsExpo, held June 9-11, 2015, at the Javits Center in New York City.
Jul. 25, 2015 12:00 PM EDT Reads: 1,529
Internet of Things is moving from being a hype to a reality. Experts estimate that internet connected cars will grow to 152 million, while over 100 million internet connected wireless light bulbs and lamps will be operational by 2020. These and many other intriguing statistics highlight the importance of Internet powered devices and how market penetration is going to multiply many times over in the next few years.
Jul. 25, 2015 09:00 AM EDT Reads: 1,482
SYS-CON Events announced today that Dyn, the worldwide leader in Internet Performance, will exhibit at SYS-CON's 17th International Cloud Expo®, which will take place on November 3-5, 2015, at the Santa Clara Convention Center in Santa Clara, CA. Dyn is a cloud-based Internet Performance company. Dyn helps companies monitor, control, and optimize online infrastructure for an exceptional end-user experience. Through a world-class network and unrivaled, objective intelligence into Internet conditions, Dyn ensures traffic gets delivered faster, safer, and more reliably than ever.
Jul. 24, 2015 11:00 PM EDT Reads: 2,054