The Classic Tag Handler Lifecycle and What It Means to You
Creating a new object is considered a relatively expensive operation in Java, even though it’s less of an issue with the latest Java runtime environments. For high-performance applications, it’s therefore common to try to minimize the number of objects created and reuse existing objects instead. The lifecycle defined for classic tag handlers in JSP 1.2 allowed a tag handler instance to be reused within the code generated for JSP pages under certain circumstances. This feature has caused a lot of pain and misunderstanding, which is why the simple tag handlers introduced in JSP 2.0 cannot be reused at all; the potential small loss of performance is a huge gain in simplicity, leading to less error prone code. For backward compatibility and for the scenarios where reuse still makes a difference, classic tag handlers are still reusable in JSP 2.0.
The classic tag handler lifecycle details are pretty complex and are
mostly of interest to container developers. But if you develop
classic tag handlers, you need to know at least how the lifecycle
relates to instance reuse to ensure that your tag handlers work
correctly in a container that takes advantage of this feature. Figure 21-7 shows a state diagram for a tag handler that
implements just the Tag
interface.
When ...
Get JavaServer Pages, 3rd Edition 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.