By: Grenfel in JSP Tutorials on 2007年10月06日 [フレーム]
There are several key differences between simple and classic tags. Let's take a quick look at each in turn and evaluate what it means to you as a tag developer.
The fundamental difference between simple and classic tags is the way in which the tag handler class is implemented. When you're using simple tags, any tag handlers you build must implement the javax.servlet.jsp.tagext.SimpleTag interface. When you're using classic tags, however, the tag handlers must implement the javax.servlet.jsp.tagext.Tag interface or, as you'll see in this chapter, one of its subinterfaces.
For you as a developer, this means you need to learn a slightly different programming model. For example, when using simple tags, all of the functionality to be encapsulated within the tag is defined within the doTag() method. When using classic tags, there are two methods you must implement: doStartTag() and doEndTag().
Feedback from tag developers over the past couple of years has been mixed, and many people find the concepts employed by classic tag handlers confusing. Therefore, the interface has been simplified and simple tags are the result of this process.
Another key, though often neglected, difference relates to the tag life cycle. With simple tags, an instance of the tag handler class is created when needed and that instance is used to serve only a single invocation of a custom tag. In other words, a unique tag handler instance is created for each usage of a simple tag on a page.
With classic tags, this may or may not be the case because the JSP specification enables container vendors to optionally improve classic tag performance by pooling and reusing tag handler instances. This means that, for example, a single tag handler instance could be created and reused to service all invocations of that custom tag per page. The rules around reuse are fairly complicated, and to make matters worse, JSP container vendors don't always choose to implement this optional piece of the specification. Therefore, if you're using classic tags, you must be aware of whether your container pools and reuses tag handler instances.
The problems that arise between different JSP containers is another reason simple tags were introduced, and it's another area in which the complexity associated with developing them has been reduced. The downside is that there may be times when you'd like tag instances pooled and reused. For example, your tag might acquire some expensive resource when it is created. In this example, it makes sense to take advantage of any performance benefits that the container may provide. In many scenarios, however, this just isn't an issue and simple tags are more than adequate.
This policy contains information about your privacy. By posting, you are declaring that you understand this policy:
This policy is subject to change at any time and without notice.
These terms and conditions contain rules about posting comments. By submitting a comment, you are declaring that you agree with these rules:
Failure to comply with these rules may result in being banned from submitting further comments.
These terms and conditions are subject to change at any time and without notice.
Most Viewed Articles (in JSP )
Show a calendar for user input in JSP
Encrypting Passwords in Tomcat using Servlets
JSP Tags for SQL to connect to a database
Steps to get a Free SSL certificate for your Tomcat
Uploading a file to a server using JSP
Server Side Programming using JSP
Latest Articles (in JSP)
Show a calendar for user input in JSP
Steps to get a Free SSL certificate for your Tomcat
Encrypting Passwords in Tomcat using Servlets
JSP Tags for SQL to connect to a database
Uploading a file to a server using JSP
Uploading an Image to a Database using JSP
A JSP page that gets properties from a bean
Scriptlets and Expressions in JSP
The taglib, tag, include, attribute and the variable Directive in JSP
Show a calendar for user input in JSP
Encrypting Passwords in Tomcat using Servlets
Steps to get a Free SSL certificate for your Tomcat
JSP Tags for SQL to connect to a database
Uploading an Image to a Database using JSP
Uploading a file to a server using JSP
© 2023 Java-samples.com
Tutorial Archive: Data Science React Native Android AJAX ASP.net C C++ C# Cocoa Cloud Computing EJB Errors Java Certification Interview iPhone Javascript JSF JSP Java Beans J2ME JDBC Linux Mac OS X MySQL Perl PHP Python Ruby SAP VB.net EJB Struts Trends WebServices XML Office 365 Hibernate
Latest Tutorials on: Data Science React Native Android AJAX ASP.net C Cocoa C++ C# EJB Errors Java Certification Interview iPhone Javascript JSF JSP Java Beans J2ME JDBC Linux Mac OS X MySQL Perl PHP Python Ruby SAP VB.net EJB Struts Cloud Computing WebServices XML Office 365 Hibernate