JSP custom label from shallow to deep detailed explanation (i)

Source: Internet
Author: User
Tags implement tld

First, the basic concept:

1. Tags (tag):

A label is an XML element that enables a JSP Web page to be concise and maintainable, and to easily implement the same JSP file to support multiple language versions. Because the label is an XML element, its name and attributes are case-sensitive

2. Tag libraries (Tag library):

A set of functionally similar, logically interrelated tags is called a tag library.

3. Tag library description file (Tag descriptor):

The tag library description file is an XML file that provides a mapping of the label references in the class and JSP in the tag library. It is a configuration file, and Web.xml is similar.

4. Label processing class (Tag Handle Class):

The label processing class is a Java class that inherits the TagSupport or extends the Simpletag interface, which enables you to implement the specific functions of a custom JSP tag

Second, the custom JSP label format:

1.

<% @ taglib prefix=”someprefix” uri=”/sometaglib” %>

For the JSP container to be able to use custom behavior in the tag library, the following two conditions must be met:

1 Identify the label representing this custom behavior from a specified tag library

2 Find specific classes to implement these custom behaviors

The first requirement-find a custom behavior that belongs to that tag library-is done by the prefix of the label directive (Taglib directive ' s Prefix), so elements that use the same prefix on the same page belong to this tag library. Each tag library defines a default prefix that is used in a document in a tag library or in a page to insert a custom label. So, you can use prefixes other than those such as JSP,JSPX,JAVA,SERVLET,SUN,SUNW (which are all reserved words specified in the JSP white paper).

The URI attribute satisfies the second requirement above. Find the corresponding class for each custom behavior. This URI contains a string that the container uses to locate the TLD file. The name of all label processing classes in the tag library can be found in the TLD file



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.