10.6. Example: Packaging the Company Name Listeners

The listeners shown in Sections 10.2 and 10.4 are very effective in keeping track of the current and former company names. However, the pages that display the names (index.jsp, Listing 10.3 and company-info.jsp, Listing 10.4) are a bit difficult to read and maintain. This difficulty is due to the need for checking if the former company name is missing before trying to display it, a test that results in quite a bit of explicit Java code in the JSP page. A perfect job for a simple custom tag!

Listings 10.14 and 10.15 show custom tags that print out the current and former company names, respectively. The first tag simply prints the current company name. The second tag uses a fullDescription attribute ...

Get More Servlets and JavaServer Pages™ now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.