Creating a new objectis considered a relatively expensive operation in Java, even thoughit’s less of an issue with the latest Java runtimeenvironments. For high-performance applications,it’s therefore common to try to minimize the numberof objects created and reuse existing objects instead. The lifecycledefined for classic tag handlers in JSP 1.2 allowed a tag handlerinstance to be reused within the code generated for JSP pages undercertain circumstances. This feature has caused a lot of pain andmisunderstanding, which is why the simple tag handlers introduced inJSP 2.0 cannot be reused at all; the potential small loss ofperformance is a huge gain in simplicity, leading to less error pronecode. For backward compatibility and for the scenarios where reusestill makes a difference, classic tag handlers are still reusable inJSP 2.0.
The classic tag handler lifecycle details are pretty complex and aremostly of interest to container developers. But if you developclassic tag handlers, you need to know at least how the lifecyclerelates to instance reuse to ensure that your tag handlers workcorrectly in a container that takes advantage of this feature. Figure 21-7 shows a state diagram for a tag handler thatimplements just the Tag interface.
Figure 21-7. Lifecycle for a tag handler implementing the Tag interfaceWhen ...