JavaBeans vs. Custom Tags

By: Emiley J Emailed: 1609 times Printed: 2077 times    

Latest comments
By: rohit kumar - how this program is work
By: Kirti - Hi..thx for the hadoop in
By: Spijker - I have altered the code a
By: ali mohammed - why we use the java in ne
By: ali mohammed - why we use the java in ne
By: mizhelle - when I exported the data
By: raul - no output as well, i'm ge
By: Rajesh - thanx very much...
By: Suindu De - Suppose we are executing

Custom tags, also known as JSP tag extensions (because they extend the set of built-in JSP tags), provide a way of encapsulating reusable functionality on JSP pages. One of the major drawbacks of scripting environments such as JSP is that it’s easy to quickly put together an application without thinking about how it will be maintained and grown in the future. For example, the ability to generate dynamic content by using Java code embedded in the page is a very powerful feature of the JSP specification. Custom tags allow such functionality to be encapsulated into reusable components. Custom tags  provide a great way for the logic behind common and recurring tasks to be wrapped up in an easy-to-use package. 

It is necessary  to know when to use tags as opposed to JavaBeans for wrapping up reusable functionality. After all, JavaBeans are reusable components and the JSP specification provides a built-in mechanism for integrating and utilizing the features provided by JavaBeans. Although both technologies can be used to achieve the same goal, that of encapsulating and abstracting data away from the JSP page, there are significant differences between the two.

JavaBeans are good general-purpose objects that encapsulate state in a portable “bucket.” We will continue to use these in our examples because they make great business objects. Tags are a web-specific technology. Tags are primarily for generating presentation elements, and as such they primarily encapsulate behavior. In addition, custom tags are aware of the environment in which they are running. For example, custom tags have access to the same implicit objects as the ones available when developing JSP pages: pageContext, request, response, session, and so on. JavaBeans, however, are components that can be reused within any Java environment; hence, they don’t know about such JSP specifics. Therefore, custom tags are a much better choice for encapsulating reusable functionality that will be used on JSP pages. Keep in mind the following rules:

  • Use JavaBeans for representing and storing information and state. An example is building JavaBeans to represent the business objects in your application.
  • Use custom tags to represent and implement actions that occur on those JavaBeans, as well as logic related to the presentation of information. An example from JSTL is iterating over a collection of objects or conditional logic.

Java Beans Home | All Java Beans Tutorials | Latest Java Beans Tutorials

Sponsored Links

If this tutorial doesn't answer your question, or you have a specific question, just ask an expert here. Post your question to get a direct answer.



Bookmark and Share

Comments(0)


Be the first one to add a comment

Your name (required):


Your email(required, will not be shown to the public):


Your sites URL (optional):


Your comments:



More Tutorials by Emiley J
Password must include both numeric and alphabetic characters - Magento
What is Hadoop?
Returning multiple values from a web service
Tomcat and httpd configured in port 8080 and 80
Java Webservices using Netbeans and Tomcat
Java WebService connected to Database
How to Deploy a Java Web Service
Call a webservice in Java
Java WebService - Create your first web service in Java
package javax.jws does not exist
Getting Started with Android
HTML5 Location - getCurrentPosition() in HTML5
HTML5 Canvas - Using Canvas in HTML5
HTML5 - Introduction
HTML5 Video - Handling video in HTML5

More Tutorials in Java Beans
Creating a JavaBean to Connect with Google API
Spring Vs EJB ( A feature comparison)
What is EJB server and what are EJB Components?
JavaBeans Basic Concepts
JavaBeans vs. Custom Tags
Java Beans and the Expression Language
A sample that shows Java Beans, Servlets and JSP working together
Advantages of Java Beans
Design Patterns for Properties in a Java Bean
javax.net.ssl.SSLHandshakeException: sun.security.validator.ValidatorException: PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target
ADVANTAGES OF EJB
Steps to develop EJB Environment
EJB is a server side component:
Entity Bean
History Of Java

More Latest News
Most Viewed Articles (in Java Beans )
javax.net.ssl.SSLHandshakeException: sun.security.validator.ValidatorException: PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target
A sample that shows Java Beans, Servlets and JSP working together
Java Beans and the Expression Language
Design Patterns for Properties in a Java Bean
JavaBeans vs. Custom Tags
Reusable component
Steps to develop EJB Environment
EJB is a server side component:
Advantages of Java Beans
What is EJB server and what are EJB Components?
ADVANTAGES OF EJB
Entity Bean
History Of Java
JavaBeans Basic Concepts
Spring Vs EJB ( A feature comparison)
Most Emailed Articles (in Java Beans)
Entity Bean
Steps to develop EJB Environment
EJB is a server side component:
JavaBeans Basic Concepts
ADVANTAGES OF EJB
JavaBeans vs. Custom Tags
What is EJB server and what are EJB Components?
Spring Vs EJB ( A feature comparison)
Reusable component
History Of Java
Advantages of Java Beans
javax.net.ssl.SSLHandshakeException: sun.security.validator.ValidatorException: PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target
Design Patterns for Properties in a Java Bean
A sample that shows Java Beans, Servlets and JSP working together
Creating a JavaBean to Connect with Google API