An in-depth study of jsp/servlet/jsf--on tag library

Source: Internet
Author: User
Tags tld

Tag Library taglib

tags are defined and distributed in a structure called a tag library, which is a collection of meta information and classes:

1. Label Processor: Java class that implements custom label functions.

2. Tag additional information (TEI): Provides a side series to the JSP container to confirm the label attributes and the class that created the variable.

3. Tag Library Descriptor (TLD): An XML document that describes the properties of a single label and the entire tag library.

Tag processor and tag additional information needs to be positioned where the JSP container class loader can be found. The tag library descriptor is available at the Fu location specified by the URL. The JSP1.1 specification requires that the JSP container accept a tag library of a jar file with a packaged genetic structure. The TLD must be a file named Taglib.tld in the/meta-inf directory, and the jar file will be copied to the/web-inf/lib directory.

First, the implementation of the label

1. Development steps

A. Define the label's name, attributes, declared variables, and the contents of the label body.

B. Write tag library descriptor TLD.

C. Write a label processor.

D. Use labels in JSP pages.

2.JSP page conversion steps in the JSP container:

There are three forms of JSP pages: JSP files, Java files, and class files.

A. Directive elements, and provide conversion-time information to the JSP container.

The b.html line is converted to the Out.print () name in the _jspservice () method.

C. The statement of the script element is copied unaltered to the source code outside the _jspservice () method.

The expression of the script element is converted sequentially into the Out.print () in the _jspservice () method.

E. The scriptlet of the script element is copied unaltered to the _jspservice () method.

F. The behavior element is converted to Run-time logic code that performs its function.

G. Custom tags are extended to Java statements that invoke methods in their corresponding label processors.

3. Tags in the JSP container conversion steps:

The a.jsp container uses the taglib directive element to locate the tag library descriptor, matching the custom tags used in the page with the TLD.

B. Read the tag list of the tag library descriptor and the name of the class associated with each label.

C. When you encounter a label on a page, look for a tag library that is related to the label prefix with the specified name.

D. The container generates a series of Java statements that complete the label function using the tag structure information found in the TLD.

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.