|
Custom-Fit Web Development
Custom tag libraries can be beneficial to both the page programmer and the designer
by Budi Kurniawan
October 2002 Issue
If you've built Web applications in Java, you've probably used JavaServer Pages (JSP). And if you've used JSP, you know that JSP development can entail tasks that repeat. Custom tag libraries are one solution to encapsulate such functionality and thus reuse it over many projects. Further, application logic can reside in server-based resources such as JavaBeans. This structure means that it's faster and easier than ever to build Web-based applications. Let's see how you can use these technologies to enhance your Web development. (For a quick description of the evolution of Web-based technologies, see the sidebar "Servlets and JSP.")
The idea behind JavaBeans and custom tag libraries is this: While the programmer works with classes that encapsulate the business logic, the Web designer can also progress with the page design. Later, the Web designer can connect to the classes from the JSP page by simple "wiring." Although the use of JavaBeans reduces the amount of code in a JSP page, you still have to do some programming to use the beans.
Custom tag libraries, however, are a powerful way of making the JSP code-free. This doesn't mean that custom tag libraries will replace JavaBeans. Both are used for separating the content from the presentation. JavaBeans are especially useful in the design where reusability of the business logic is important. JavaBeans normally can be used by various pages in different projects. On the other hand, custom tag libraries are customized for a particular page, even though reusable custom tag libraries are also commonplace. One way to get custom tag libraries is to build your own. But why reinvent the wheel? The Jakarta Taglibs project (from the Apache Software Foundation), for instance, provides custom tag libraries that can be used again and again in different JSP applications.
Back to top
|