JSP Tag Library Introduction (2) turn

Source: Internet
Author: User
Tags include interface new features xsl xsl file
JS what is a tag library?
The JSP Tag library (also known as custom tags) is a way to generate xml-based scripts via JavaBean. Conceptually, a label is a simple and reusable code structure. For example, in our latest release of Jspkit (within the JSP Insider), we use XML tags to implement easy access to XML documents. Please look at the following list A.

Listing A: Sample tags that perform xml/xsl conversions and their HTML pages

<%@ taglib uri= "Http://www.jspinsider.com/jspkit/JAXP" prefix= "JAXP"%>
<JAXP:TransformerTag>
<JAXP:XMLFile>c:/xml/example.xml</JAXP:XMLFile>
<JAXP:XSLFile>c:/xml/example.xsl</JAXP:XSLFile>
</JAXP:TransformerTag>

The above example uses a simple tag to access more powerful code behind the scenes. In the above case, an XML file was first loaded, and then an XSL file was applied to create a result that would be sent to the client-all but just a simple tag.

Custom tags make it easy to create reusable open source modules in JSP projects. And all you need is a tag library and its documentation. The key features of the tag library are as follows:

Easy to install on multiple projects
Tags are easy to migrate from one JSP project to another. Once you have set up a tag library, you only need to wrap the tag library into a jar file to reuse it in other JSP projects. What you can't reuse is the label you add to the label as a programmer. Because tags can be reused, tag libraries can be easily used for your own projects. At present, the best tag resources can be found at the jsptags.com site.
Extend JSP
The tag library can have any of the features and functionality in the JSP specification (JSP 1.2). This also means that you have unlimited ability to expand and increase the functionality of the JSP without waiting for the release of the new version of JSP. So you can completely cancel the JSP include call on the page-just use the include tag to set up your own specifications.
Easy to maintain
Tag libraries make JSP Web applications easy to maintain. There are several main reasons for this:


Tags are easy to use and easy to understand for anyone.
All of your logic resides in the center of the tag processor and JavaBean. This way, if you have to update your code, you just have to process the center files without having to fix other pages that use the code.
If you need to add new features, you don't have to change any pages that already exist. You can include additional attributes into your tags to introduce new behaviors while preserving the previous attributes to enable the normal operation of the old page.

For example, you might have a tag like the following, which gives your text a blue display:

<bluetext>my text</bluetext>

But as the project goes on, you want to darken the blue. So you keep your label but add a new attribute to it: shade

<bluetext shade= "Teal" >my text</bluetext>

All the old tags continue to show blue, but now you can use the same label to produce dimmed blue text.


tags enhance the reusability of your code. The code that has been tested and used more than once is sure to have fewer bugs. Therefore, the use of custom tags JSP page also has fewer defects, the maintenance of natural more convenient.
Faster speed of development
Tag libraries are a good way to reuse code. We know that server-side language standard reuse code is the use of templates. tag libraries and template libraries are much better than this way. With a template library, you need to modify the template for each project or create a stiff interface. Tag libraries do not have these limitations, and the object-oriented nature of the tag library makes it not only flexible but also extremely extensible. Also, because you reuse code, the result is much less time spent on project development and more time can be used to design your own Web application. The simple interface of the tag library makes these code usage simple and easy to debug.
Although the tag library is particularly simple to use, it is much more complicated to build its internal support hierarchy than to build simple javabean. The main reason for this complexity is that the tag library contains several parts. The skills you need to master are just understanding, familiarity with Java and JSP.


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.