JavaBeans versus Custom Tag Libraries

As we can see from these examples, we have two different approaches available to placing content on the JSP page: using JSP scriptlets and tags (getProperty, setProperty) or using custom tags. The differences between the implementation of these two approaches becomes more apparent as we examine the code behind these JSP pages in more detail. While the two approaches share many similarities, there are distinct differences between the structure of the Java code required for each, and later in this chapter we discuss both solutions and provide recommendations on where each is considered appropriate.

The following sections present both approaches, using both the calendar JavaBean and the custom tag library. The ...

Get J2EE™ and Beyond: Design, Develop, and Deploy World-Class Java™ Software now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.