ColdFusion MX introduced the ability for developers to import JSP tag libraries into their own applications. This is very simple and requires the use of a new CFMX tag, <cfimport> . In this section, we'll briefly see how to use it. Let's do that by contrasting how a JSP imports a tag library for use:
In JSP:
<%@ taglib uri="mylibrary.tld" prefix="ecommerce" %>
In CFMX:
<CFIMPORT taglib="/WEB-INF/lib/mytags.jar" prefix="ecommerce">
It is very easy to use JSP tag libraries in ColdFusion this way. All you have to do is download your tag library, place the .jar file in the WEB-INF/lib directory as you would in Tomcat, write your <cfimport> tag, and reference the tag on that CFML page. However, there are a couple of things to look out for:
You cannot call the <cfimport> tag in your application.cfm file as a shortcut to make it available to all of your CFML pages.
You cannot define the library in a CFML page other than the one in which you use it; that is, you cannot <cfinclude> it.
With regular CFMX tags, there is a central location where you can store custom tags and have them available to the entire server. This is not the case with imported JSP tag libraries. You must deploy it separately with each application.
That's all there is to it.
Top |