知方号

知方号

21.2.5. The Classic Tag Handler Lifecycle and What It Means to You

The Classic Tag Handler Lifecycle and What It Means to You

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 interface

When ...

版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容, 请发送邮件至lizi9903@foxmail.com举报,一经查实,本站将立刻删除。