JSP Tag Library Introduction (3) turn

Source: Internet
Author: User
Tags define tld
JS Custom Label Insider
A simple custom tag consists of the following elements:


JavaBean: In order to take full advantage of the object-oriented nature of Java, reusing code should be placed in a separate code container. These javabean are not part of the tag library. They are the base code module used by the tag library to perform the assigned tasks.
Tag Processor: This is the real core of the tag library. The label processor (tag handler) references any external material it needs (JavaBean) and is responsible for accessing the information (PageContext object) of the JSP page. The JSP page will be set on the page label properties are passed to the label processor, JSP page label on the contents of the content is handled. When the label processor completes its processing process, it sends the processed output back to the JSP page for further processing.
Tag Library descriptor (TLD file): This is a very simple XML file that describes and illustrates information such as attributes, information, and label processor file locations. The JSP container uses this file to map the location and usage of the called Tag Library.
Web.xml file for a Web site: This is actually the initialization file on your Web site. In this file you can define the custom tags used in the Web application, and you can define the TLD file that describes each custom label.
Publish a file (war or jar file): If you're going to reuse custom tags, you'll need to think of a simple way to move labels from one project to another. Packaging the tag library into a jar file is a convenient and efficient way to publish the tag library. We don't have a jar file in the above case, but if you're going to go further into the details of the jar file, you might as well read the "Introduction to the JSP War file."
Tag Library declaration on a JSP page: You can easily declare labels that exist on a page simply by using the tag library identifier. Once the tag library is declared on the page, you are free to use them.
Looks like it'll keep you busy for a while, but it's not that bad. It's a bit tricky at first. What really matters is not the coding but the proper organization of these parts. This hierarchical structure is very important, and that is how it can be said that tag library and flexible and easy to use. More importantly, these layers allow the entire process of building tag libraries to be automatically completed through the JSP IDE. Future JSP Ides can automate most of the work of creating custom tags, but you only need to be responsible for creating code and tag processors.

(Note: A label processor defines only one custom tag; a tag library is a collection of many tag processors that perform the same task.) )


Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.