Java
  Home arrow Java arrow Page 6 - Overview of Java Web Technologies, Part 2
Dev Shed Forums  
Administration  
AJAX  
Apache  
BrainDump  
DHTML  
Flash  
Java  
JavaScript  
Multimedia  
MySQL  
Oracle  
Perl  
PHP  
Practices  
Python  
Reviews  
Security  
Smartphone Development  
Style-Sheets  
Web Services  
XML  
Zend  
Zope  
Mobile Linux  
App Generation ROI  
IBM® developerWorks  
Forums Sitemap  
E-Commerce Hosting  
Linux Web Hosting  
Managed Hosting  
Small Business Hosting  
VPS Hosting  
Weekly Newsletter

 
Developer Updates  
Free Website Content 
 RSS  Articles
 RSS  Forums
 RSS  All Feeds
Write For Us Get Paid  
Request Media Kit
Contact Us  
Site Map  
Privacy Policy  
Support  
 USERNAME
 
 PASSWORD
 
 
  >>> SIGN UP!  
  Lost Password? 
JAVA

Overview of Java Web Technologies, Part 2
By: McGraw-Hill/Osborne
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: starstarstarstarstar / 8
    2004-03-03


    Table of Contents:
  • Overview of Java Web Technologies, Part 2
  • Sun's Solution
  • JSP and JavaBeans
  • Calling a Bean from a JSP Page
  • Accessing Bean Properties
  • Custom Tags
  • Developing and Using Custom Tag Libraries
  • Writing a Tag Handler
  • Writing and Using Tags
  • Model 2 Architecture

  • Rate this Article: Poor Best 
      ADD THIS ARTICLE TO:
      error-file:tidyout.log Del.ici.ous error-file:tidyout.log Digg
      error-file:tidyout.log Blink error-file:tidyout.log Simpy
      error-file:tidyout.log Google error-file:tidyout.log Spurl
      error-file:tidyout.log Y! MyWeb error-file:tidyout.log Furl
    Email Me Similar Content When Posted
    Add Developer Shed Article Feed To Your Site
    Email Article To Friend
    Print Version Of Article
    PDF Version Of Article

     
     
    ADVERTISEMENT


    Overview of Java Web Technologies, Part 2 - Custom Tags
    ( Page 6 of 10 )

    Using JavaBeans allows you to separate the presentation part of a JSP page from the Java code. However, only three action elements—jsp:useBean, jsp:getProperty, and jsp:setProperty—are available for accessing a bean. Therefore in some situations, we need to resort to using code in a JSP page. In other words, in many cases, JavaBeans do not offer complete separation of presentation and business rule implementation.

    Also, JavaBeans are designed with reusability in mind, meaning that using a bean to output HTML tags directly is not recommended. Outputting HTML tags from a bean makes the bean usable only from a certain page.

    In recognition of the imperfection of JavaBeans as a solution to separation of presentation and business rule implementation, JSP 1.1 defined a new feature: custom tags that can be used to perform custom actions. For example, the following JSP page uses custom tags:

     
    <%@ taglib uri="/myTLD" prefix="c"%> 
    <html
    <head
    <title>Using custom tags</title
    </head
    <body
    <c:myTag/> 
    </body
    </html

    As you can see, the JSP page above is free from Java code. On the first line, you declare that you are using a custom tag in the JSP page, and on the seventh line, you use the custom tag itself. The result output by the <c:myTag/> tag depends on the Java class associated with the custom tag.

    Understanding how to use and develop custom tags is important in developing JSF applications, because, in fact, JSF uses custom tags extensively.

    To use custom tags, you must develop a custom tag library. We will examine the process of creating custom tag libraries and using them from JSP pages in detail. But first, we’ll take a look at the differences between JavaBeans and custom tags.

    Comparing Custom Tags with JavaBeans

    Compared to JavaBeans, custom tags offer some advantages:

    • Custom tags have access to all the objects available to JSP pages.
    • Custom tags can be customized using attributes.

    However, custom tags have the disadvantage of being slightly harder to build and use than JavaBeans. Sometimes, JavaBeans are preferable because of their reusability. There is no hard-and-fast rule governing whether to use JavaBeans or custom tags. You often need to decide which one to use based on the particular project’s specifications.

    Buy this book now!Remember: This is part two of the first chapter of JavaServer Faces Programming, by Budi Kurniawan (McGraw-Hill/Osborne, ISBN 0-07-222983). Stay tuned for more chapters of developer books from McGraw-Hill/Osborne.
    Buy this book!



     
     
    >>> More Java Articles          >>> More By McGraw-Hill/Osborne
     

       

    JAVA ARTICLES

    - Exception Handling Techniques in Java
    - More About Multithreading in Java
    - The Basics of Multiple Threads in Java
    - Data Access Using Spring Framework JDBC
    - New Object Initialization in Java
    - Adding Images With iTextSharp
    - Adding Columns With iTextSharp
    - Creating Simple PDF Files With iTextSharp
    - The Spring Framework: Understanding IoC
    - Introducing the Spring Framework
    - Java Classes
    - Completing the Syntactic Comparison of Java ...
    - Syntactic Comparison of Java and C/C++
    - Java Statements
    - Conditionals, Expressions and Other Java Ope...





    © 2003-2009 by Developer Shed. All rights reserved. DS Cluster 6 Hosted by Hostway
    Stay green...Green IT