JSPs can use tag libraries to serve content formatted with custom tags. The tag library is a Java class with methods to parse content that is tagged with custom tags and output formatted content to be returned in the response stream. Each tag library must have a Type Library Descriptor (TLD) file that describes the available tags and specifies the corresponding Java classes and methods.
JSPs use a type library by specifying the location of the TLD file as a URL. In your Web application, you can specify a mapping so that TLD URLs in JSPs map to a local URL. For example, you may refer to a tag library as follows in a JSP:
<%@ taglib uri="/example.tld" prefix="ex" %>
This path can be mapped to another location, such as:
/WEB-INF/tlds/PRlibrary_1_4.tld
You do not have to map TLD URLs in the Web application. If there is no mapping that matches a TLD URL, EAServer loads the file at the URL specified in the JSP and raises an error if the file does not exist.
Mapping TLD URLs provides several benefits such as:
You can keep TLD files together in a common location.
You can avoid multiple copies of a TLD when JSPs use different paths to refer to the same type library.
You can code JSPs with simple paths, such as tlds/example.tld, while the actual TLD is stored in a versioned directory tree. For example, you can alias tlds/example.tld to WEB-INF/tlds/example/v1.6/example.tld. This mapping allows you to easily test new versions and roll back to previous versions if a problem occurs.
In an XML deployment descriptor, TLD URL mappings are specified by taglib elements.
Tag library classes A Web application’s tag library classes must be deployed in the WEB-INF/lib or WEB-INF/classes directories, with the other Java classes required by your Web application. See “Java classes” for more information.
Configuring TLD mappings in EAServer Manager
Display the Advanced tab in the Web Application Properties dialog box.
If necessary, add an entry for the property com.sybase.jaguar.webapplication.taglib
.
Otherwise, modify the existing value for this property.
In the property value, specify each mapping as follows:
(taglib-uri=alias, taglib-location=real-path)
Where alias is the path used in JSP source code, and real-path is the TLD file’s location relative to the Web application’s context root.
If multiple mappings are required, separate each by a comma. For example (the following must be entered without line breaks or carriage returns):
(taglib-uri=taglib.tld, taglib-location=TLD/abctaglib.tld), (taglib-uri=lib2.tld,taglib-location=TLD/lib2v2.tld)
Copyright © 2005. Sybase Inc. All rights reserved. |