One of the most exciting features about JSP is the ability tobuild and use custom "tag libraries" in your JSP applications. In thisarticle, find out why tag libraries are a Good Thing, and read about how toget and install custom tag libraries for common tasks.
One of the most exciting features about JSP is the ability to build and use custom "tag libraries" in your JSP applications. A "tag library" is a reusable block of JSP code, typically written to replace Java code with easy-to-read-and-understand tags (similar in appearance to HTML markup). Once written, these tag libraries can be used over and over again, thereby bringing a new element of reusability to the language.
In addition to reusability, tag libraries also offer substantial advantages from the maintenance point of view. Since tag libraries are largely defined using XML-type markup, they make it possible to separate application presentation from application logic - which, in turn, implies that designers and developers working on Web applications can use a tag without worrying about how and why it works. This separation between program code and final layout is something most designers would kill to have - and it's now available to almost anyone who knows how to string together Java and JSP code.
Another advantage of the separation discussed above, is the ease of use when it comes to adding new features to a tag library, or making changes to existing features. Since a tag library is portable and reusable, a change made to it will immediately reflect in all JSP pages using that tag library. Similarly, a new feature added to the tag library becomes immediately available to all pages carrying that library.
Tag libraries are slowly catching on, with many JSP developers releasing custom tag libraries for free online. These libraries are typically designed for specific tasks - database connectivity, string manipulation and the like - and they provide a rich vein for JSP developers to mine for their own projects. After all, why waste time writing Java code to send email messages when you can find a feature-rich, properly-tested and free tag library to do the same thing online?