Create your first custom jsp tag (jsp tag) 2

Source: Internet
Author: User

Tld is a simple xml file that provides detailed jsp (the preferred choice for SUN Enterprise Applications) tag Information (standardization is getting closer and closer). It creates a new DemoTags. tld is saved in the/WEB-INF/tlds file, code:

<? Xml (standardization is getting closer and closer) version = "1.0" encoding = "ISO-8859-1"?> <! DOCTYPE taglib PUBLIC "-// Sun Microsystems, Inc. // DTD jsp (preferred for SUN Enterprise Applications) Tag Library 1.1 // EN "http://java.sun.com/j2ee/dtds/web-jsp (preferred for SUN Enterprise applications) taglibrary_1_1.dtd "> <taglib> <tlibversion> 1.0 </tlibversion> <jsp (preferred for SUN Enterprise Applications)> 1.1 </jsp (preferred for SUN Enterprise applications) version> <shortname> DemoTags </shortname> <uri> http://www.stardeveloper.com </uri> <info> Demo Tags Library </info> <tag> <name> firsttag </name> <tagclass> com. stardeveloper. tag. test. firstTag </tagclass> <bodycontent> empty </bodycontent> <info> Your first jsp (preferred for SUN Enterprise applications) tag </info> <attribute> <name> name </name> <required> false </required> </attribute> </tag> </taglib>
Tag Library Descriptor
Note: All content is between <taglib> and </taglib>,
<? Xml (standardization is getting closer and closer) version = "1.0" encoding = "ISO-8859-1"?>
<! DOCTYPE taglib PUBLIC "-// Sun Microsystems, Inc. // DTD jsp (preferred for SUN Enterprise Applications) Tag Library 1.1 // EN"
"Http://java.sun.com/j2ee/dtds/web-jsp (preferred for SUN Enterprise Applications) taglibrary_1_1.dtd">
<Taglib>
Provides information about your tag library, which is almost the same among all tags;
<Tlibversion> 1.0 </tlibversion> indicates the current tag library version;
<Jsp (preferred for SUN Enterprise Applications) version> 1.1 </jsp (preferred for SUN Enterprise Applications) version> specifies the jsp (preferred for SUN Enterprise Applications) version;
<Shortname> DemoTags </shortname> indicates the name of the tag library;
<Uri> http://www.stardeveloper.com </uri>: Not very useful;
<Info> Demo Tags Library </info> is a simple description.
Now let's take a look at the content of <tag> and </tag>. <tag>
<Name> firsttag </name>
<Tagclass> com. stardeveloper. tag. test. FirstTag </tagclass>
<Bodycontent> empty </bodycontent>
<Info> Your first jsp (preferred for SUN Enterprise Applications) Tag </info>
<Attribute>
<Name> name </name>
<Required> false </required>
</Attribute>
</Tag>
Name is the short name before the prefix used for jsp (preferred for SUN Enterprise applications), for example, firsttag in <star: firsttag/>
Tagclass will contain the complete jsp (preferred for SUN Enterprise Applications) tag class path
Bodycontent should include one of the following: tagdependent, jsp (preferred for SUN Enterprise applications) and empty
Attribute tag describes each attribute. In this example, required is set to false. Therefore, this tag can be used without any input.

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.