Java程序员应该掌握的10个JSP标签库
One of JSP’s most overlooked features is its ability to work with reusable code blocks, aka “tag libraries,” to add new functionality to a JSP application. These tag libraries, declared using XML-type markup, provide ready-to-use widgets that can easily be integrated into a JSP page. They’re also a useful way to separate an application’s business logic from its visual presentation.
There are lots of freely available libraries online — but how do you know where to start? The 10 JSP tag libraries listed in Table A provide a starting point for your journey into the world of JSP reusability. Take a look.
Note: To install JSP tag libraries, refer to the documentation and to the installation instructions included with each library.
Table A
Package Name |
Description |
Standard | This library is a must-have, because it incorporates a number of core enhancements to regular JSP. Some of its features include an XML manipulation library, an SQL library, special internationalization capabilities, and support for iterators and other program control mechanisms. Use this library when you need advanced flow control structures, internationalization capabilities, or XML support. |
DateTime | This library provides various tools for date and time manipulation, including the ability to retrieve the current date and time, generate lists of days and months, format dates and times, and convert between time zones. Use this library to easily bring date and time manipulation routines into your application. |
Mailer | This library adds e-mail delivery capabilities to your JSP application by including support for sending mail through a user-defined SMTP server. It also includes support for multiple recipients, custom headers, MIME attachments and error handling. Use this library when you need to create and send e-mail messages in a JSP page. |
Cache | This library provides a simple caching framework for a Web site. It allows you to cache sections of a page and reduce response times by rendering the cached pages to clients. If your site receives a lot of traffic, use this package to reduce server load and page processing time by occasionally providing clients with snapshots from the page cache instead of the “live” page. |
XTags | This library provides routines to simplify parsing and transforming XML documents with XSLT. It can be used to apply an XSLT transformation to an XML document, add or remove XML nodes, evaluate XPath expressions, and define template rules. Use this library when you need advanced XML/XSLT processing capabilities. |
Regexp | This library allows you to use Perl5-compatible regular expressions in your JSP applications. The library includes support for Perl’s match (m), replace (s) , and split operators. Use this library when you need regular expression support for pattern matching and substitution. |
JSP Controls | This library allows you to create individual page components, such as login forms or progress bars, which may be independently updated. It is particularly useful for AJAX applications, although it may also be used in non-AJAX mode. Use this library when building AJAX-type JSP applications. |
Pager | This library implements a paging system for data sets, making it simple to incrementally move forward and backward through large data sets (such as database search results). It also includes various paging styles and support for a browsable result index. Use this library when you need a quick-and-dirty paging system for your application. |
JDBForms | This library makes it possible to link database connections with form elements and create custom actions to rapidly simplify the development of database-driven Web applications. It includes support for sorting, searching, filtering, and styling and uses a SWING-based interface. Use this library for rapid development of database-backed JSP applications. |
Google Tag Library | This library makes it possible to perform and process Google searches, check spellings, and access pages in the Google.com cache. Use this package to add Google.com search capabilities to your site or to create a search engine that uses the Google.com database. |