Class of the Month: JSP Tag Libraries and the TagSupport Class

JSP Tag libraries provide a convenient framework for developing Web applications. They allow you to wrap custom functionality inside XML-like tags.

provided by: 
Originally published at Internet.com


JSP Tag libraries provide a convenient framework for developing Web applications. They allow you to wrap custom functionality inside XML-like tags. By removing the "details" from the JSP page, it becomes easier to read. At the end of the day, however, JSP pages along with JavaBeans and tag libraries, get translated into servlets. So at runtime, it is the servlet that does the work.

Piroz Mohseni

With tag libraries, you can declare a custom tag and then associate some code with it and control when the code is invoked in relation to the opening or closing tags. The key class to make this work is TagSupport, which is part of the javax.servlet.jsp.tagext package. Note that this is not standard Java API. Most likely it will ship with your JSP/servlet engine, like Apache Tomcat.

A JSP page (regardless of whether it contains tag libraries or not) is processed from top to bottom. In a manner similar to the SAX API, various events are associated with this reading process. These "events" correspond to when the reader encounters a tag that is part of the tag library defined for the page. When the tag is first encountered, the doStartTag() method of TagSupport is called. By inheriting from TagSupport and overriding the doStartTag(), you can associate custom code and functionality to that event. As the reading process continues, it will eventually encounter the closing tag for the element and at that time it invokes the doEngTag() method...

Read article at Internet.com site
Regional Articles
- Class of the Month: JSP Tag Libraries and the TagSupport Class Alabama
- Class of the Month: JSP Tag Libraries and the TagSupport Class Alaska
- Class of the Month: JSP Tag Libraries and the TagSupport Class Arizona
- Class of the Month: JSP Tag Libraries and the TagSupport Class Arkansas
- Class of the Month: JSP Tag Libraries and the TagSupport Class California
- Class of the Month: JSP Tag Libraries and the TagSupport Class Colorado
- Class of the Month: JSP Tag Libraries and the TagSupport Class Connecticut
- Class of the Month: JSP Tag Libraries and the TagSupport Class DC
- Class of the Month: JSP Tag Libraries and the TagSupport Class Delaware
- Class of the Month: JSP Tag Libraries and the TagSupport Class Florida
- Class of the Month: JSP Tag Libraries and the TagSupport Class Georgia
- Class of the Month: JSP Tag Libraries and the TagSupport Class Hawaii
- Class of the Month: JSP Tag Libraries and the TagSupport Class Idaho
- Class of the Month: JSP Tag Libraries and the TagSupport Class Illinois
- Class of the Month: JSP Tag Libraries and the TagSupport Class Indiana
- Class of the Month: JSP Tag Libraries and the TagSupport Class Iowa
- Class of the Month: JSP Tag Libraries and the TagSupport Class Kansas
- Class of the Month: JSP Tag Libraries and the TagSupport Class Kentucky
- Class of the Month: JSP Tag Libraries and the TagSupport Class Louisiana
- Class of the Month: JSP Tag Libraries and the TagSupport Class Maine
- Class of the Month: JSP Tag Libraries and the TagSupport Class Maryland
- Class of the Month: JSP Tag Libraries and the TagSupport Class Massachusetts
- Class of the Month: JSP Tag Libraries and the TagSupport Class Michigan
- Class of the Month: JSP Tag Libraries and the TagSupport Class Minnesota
- Class of the Month: JSP Tag Libraries and the TagSupport Class Mississippi
- Class of the Month: JSP Tag Libraries and the TagSupport Class Missouri
- Class of the Month: JSP Tag Libraries and the TagSupport Class Montana
- Class of the Month: JSP Tag Libraries and the TagSupport Class Nebraska
- Class of the Month: JSP Tag Libraries and the TagSupport Class Nevada
- Class of the Month: JSP Tag Libraries and the TagSupport Class New Hampshire
- Class of the Month: JSP Tag Libraries and the TagSupport Class New Jersey
- Class of the Month: JSP Tag Libraries and the TagSupport Class New Mexico
- Class of the Month: JSP Tag Libraries and the TagSupport Class New York
- Class of the Month: JSP Tag Libraries and the TagSupport Class North Carolina
- Class of the Month: JSP Tag Libraries and the TagSupport Class North Dakota
- Class of the Month: JSP Tag Libraries and the TagSupport Class Ohio
- Class of the Month: JSP Tag Libraries and the TagSupport Class Oklahoma
- Class of the Month: JSP Tag Libraries and the TagSupport Class Oregon
- Class of the Month: JSP Tag Libraries and the TagSupport Class Pennsylvania
- Class of the Month: JSP Tag Libraries and the TagSupport Class Rhode Island
- Class of the Month: JSP Tag Libraries and the TagSupport Class South Carolina
- Class of the Month: JSP Tag Libraries and the TagSupport Class South Dakota
- Class of the Month: JSP Tag Libraries and the TagSupport Class Tennessee
- Class of the Month: JSP Tag Libraries and the TagSupport Class Texas
- Class of the Month: JSP Tag Libraries and the TagSupport Class Utah
- Class of the Month: JSP Tag Libraries and the TagSupport Class Vermont
- Class of the Month: JSP Tag Libraries and the TagSupport Class Virginia
- Class of the Month: JSP Tag Libraries and the TagSupport Class Washington
- Class of the Month: JSP Tag Libraries and the TagSupport Class West Virginia
- Class of the Month: JSP Tag Libraries and the TagSupport Class Wisconsin
- Class of the Month: JSP Tag Libraries and the TagSupport Class Wyoming

Rss   Delicious   Digg   Add To My Yahoo   Add To My Google   Bookmark   Search Plugin

Topics:
Architecture & Design Languages & Tools Project Management Web Services
Database Microsoft & .NET Security Wireless
Java Open Source Techniques XML