Skip to main content

Tag Libraries

Posted by daniel on October 8, 2003 at 2:57 PM PDT

There is always tension between programmers who design and develop JSP pages and the content providers who author or edit these pages. How much programming should a page author need to know?


Sue Spielman's feature article Practical JSTL begins "The JSTL allows page authors to make use of easy-to-learn, easy-to-use standard actions for common ways we deal with presentation." She stresses that the key is having a standard set, "Having a defined specification for how the functionality is implemented means that a page author can learn these custom actions once and then use and reuse them on all future products on all application containers that support the specification."

In her first example, Spielman shows using an if tag together with the Expression Language to get the following code.

<c:if test="${book.orderQuantity > book.inStock}">
The book <c:out value="${book.title}"/> is currently out of stock.
</c:if>

The JSTL does simplify the required code. As a developer you should find that code easy to read. This would not be very obvious to a non-technical person. In other words, building a complex page still requires an understanding of programming. Spielman writes that it is easier to read and understand a request written like this

The title of the book you just purchased is
<c:out value="${sessionScope.bookInfo.title}">

than it is to read a request written like this.

<%@page import="com.mk.jstl.bookInfo"%>
<%BookInfo bookInfo =(BookInfo)session.getAttribute"
("bookInfo");
%>
The title of the book you just purchased is
<%=bookInfo.getTitle()%>

Although that's true, it still requires programming. The JSTL promises simplification and consistency. Sue Spielman's two part series gives you a nice overview of the possiblities when using standard tags.


Simon Brown's Weblog entry picks up on the tagging theme and asks How do you test tag libraries? This discussion is sparked by the question "aren't you using JSPs to test JSPs?" Brown answers "JSP tags are reusable components and I think that they should be tested as such. For me, this means testing those tags in the same way that they will be used on a JSP page, and that's by writing the tests and assertions as JSP pages. "


In Also in Java Today we link to a ServerSide article based on an excerpt from Ernest Friedman-Hill's book "Jess in Action". In Jess and the javax.rules API .
The javax.rules APIs allows your Java application to interact with rules engines and includes "mechanisms for creating and managing sets of rules; for adding, removing, and modifying objects in working memory; and for initializing, resetting, and running the engine. "

In his developerWorks article Advanced DAO programming , Sean C.Sullivan helps you decide whether your situation is better served by using JTA or JDBC for transaction marking.by encouraging you to consider how transactions begin and end, which object is responsible for each, and how and when the transaction and DAO(s) communicate. He also encourages you to handle exceptions and pay attention to logging.


Today in Projects and Communities,

visit the Japanese Jakarta Users group. This member of the java.net Java Users Group is formed to internationalize Jakarta applications and to translate them to Japanese. The Jini community has a new community standard. The Jini entries for JMX Remote API has passed the Jini Community Decision Process..


In today's java.net News Headlines :

Registered users can submit news items for the href="http://today.java.net/today/news/">java.net News Page using our
news submission form.
All submissions go through an editorial review by news director Steve
Mallet before being posted to the site. You can also subscribe to the href="http://today.java.net/pub/q/news_rss?x-ver=1.0">java.net News RSS
feed.


Current and upcoming Java Events:

Registered users can submit event listings for the href="http://www.java.net/events">java.net Events Page using our href="http://today.java.net/cs/user/create/e"> events submission form.
All submissions go through an editorial review before being posted to the
site.


This blog is delivered weekdays as the href="http://today.java.net/pub/q/java_today_rss?x-ver=1.0">Java Today RSS
feed. Once this page is no longer featured as the front page of href="http://today.java.net"> Java Today it will be archived at href="http://today.java.net/today/archive/index_10082003.html">
http://today.java.net/today/archive/index_10082003.html. You can
access other past issues in the href="http://today.java.net/today/archive/">java.net Archive.