|
The JavaServer Pages (JSP) 1.1 specification allows JSP developers to create their own action tags--to provide custom functionality that is invoked by a defined set of HTML-like tags. Custom tag libraries provide developers with the ability to distill down complex server-side behaviors into simple and easy to use elements that content developers can then incorporate into their JSP pages. This article, the first of two parts, explores the Jakarta Taglibs Project (part of the not-for-profit Apache Software Foundation), which provides a wide array of open-source custom tag libraries for use in JavaServer Pages. First, a brief review of the concept of custom tag libraries is offered, followed by an overview of the workings of the Jakarta Taglibs Project and its various custom tag libraries, and concluding with the open-source development experiences of several members of the Jakarta community. Part II of this article will explore several recently released Jakarta taglibs, as well as one that is currently in development, and offer sample code that uses these new libraries.
A Review of Custom JSP Tags
Using a custom tag library within a JSP page is relatively simple. The
The
The
Given the above
Custom tag libraries encourage a clean division of labor between library developers and library users, greatly reducing, or even eliminating, the need to embed Java code directly in JSP pages. Tag libraries are created by developers, who are proficient with the Java programming language, and expert at accessing data and system services. Tag libraries are used by web content designers, who can then better focus on presentation issues. Custom tags accomplish some of the same goals as JavaBeans that are used within a JSP. But they have numerous other advantages. Custom tag features:
On the custom tag library developer end, tag actions are defined using tag handlers. Tag handlers are server side objects used at runtime to evaluate and effect the intended actions of the custom tags. A tag handler must implement one of two interfaces-- Meanwhile, a tag library description (TLD), written in XML, is used to describe the composition of a given tag library. This information includes detail on the individual tags and mappings to their tag handlers, version information on the JSP container, the tag library, and so on.
Jakarta Taglibs ProjectThe goal of the Jakarta Project is to provide commercial-quality server solutions based on the Java platform that are developed in an open and cooperative fashion. Jakarta, part of the not-for-profit Apache Software Foundation, is the overall project name that encompasses many different subprojects. Tomcat is the Servlet + JSP Engine that is a subproject of the greater Jakarta Project. Another Jakarta subproject is Jakarta Taglibs. Sun Microsystems licensed its JavaServer Pages technology to the Apache developer community in June of 1999. Since then, a burgeoning JSP development community has taken hold at Jakarta. The Jakarta Project operates on a meritocracy--the more you do, the more responsibility you will obtain. As a result, there is room for contribution within this open-source development effort at a variety of different levels. Jakarta users are those who simply use the products of the Project. They aren't necessarily contributing code, but they are using the products, reporting bugs, making feature requests, and so on. In many ways, these are the most important members of the project. It is with this feedback that the products grow and evolve. When users begin to contribute code, they become developers. Developers are those that write code or document patches, or contribute positively to the project in other ways. Developers who provide frequent and valuable contributions to a Jakarta subproject can be promoted to the status of committer. A committer has write access to the source code repository, and gains voting rights that allow him or her to effect the future of the subproject. Developers can either be nominated for committer status by another committer, or nominate themselves. At that point, the other committers of the subproject will vote on the proposal. If there are at least three positive votes, and no negative votes, then the developer is promoted to the status of committer, and given write access to the source code repository for that subproject. Finally, committers who regularly participate and make valuable contributions may have their status promoted to project manager committee member. The Project Management Committee (PMC) is the official managing body of the Jakarta Project, and is responsible for setting overall project direction. To become a member, a current PMC member must nominate the committer, and he or she must be approved by a 75% majority of the PMC. The Jakarta Project obtains its strength and usefulness via the ongoing communication and interaction between its members. The Taglib Project has several email lists for this purpose. The Jakarta Taglibs user mailing list is used to send questions and comments about configuration, setup, usage, and other user types of questions. The Jakarta Taglibs developer mailing list is used to send questions and comments about the actual software source code, and general development types of questions. All developers are encouraged to participate and offer suggestions, but the ultimate decision is made by those that have committer status. Any developer may also vote on an issue or action item, but the only binding votes are those made by committers. Meanwhile, the act of voting carries responsibilities. Voting members are not only stating an opinion, they are agreeing to help do the work. Each committer vote can be cast in one of four flavors:
An action requiring consensus approval must receive at least three binding +1 votes, and no binding vetoes. An action requiring majority approval must receive at least three binding +1 votes, and more +1 votes than -1 votes. Jakarta Taglibs
Recent Jakarta TaglibsThe Jakarta Taglibs Project has recently released several new taglibs--JDBC and Scrape, with another one, Tag Pipelining, currently in the development stages. Part II of this series, will explore those taglibs in greater technical depth. The Jakarta members involved in the JDBC, Scrape, and Tag Pipelining libraries came to Jakarta through different paths. But the story of each illustrates the strength of both custom JSP tag libraries, and the Jakarta open-source development process.
"The Jakarta taglibs project is a great way to get involved with open-source," says Pierre Delisle, Staff Engineer for Sun Microsystems. Delisle is a committer for several Jakarta taglibs, and is currently working on the concept of "tag pipelining" with James Strachan, a consultant at Metastuff Ltd. out of London, England. The goal of tag pipelining is to allow the output of one JSP custom tag to transparently serve as the input for another tag--in the classic sense of pipes in the UNIX platform. One advantage of the Jakarta taglibs is that each tag library is its own well-defined mini-project. "The cost of entry into the open-source world within this context is minimal," says Delisle. "Contributing to the project doesn't involve a steep learning curve, as is often the case with other more complex projects. Just think of a cool idea for a tag library, and the community will be happy to see you contribute it to the project." Morgan Delagrange is a Senior Systems Architect for Britannica.com. But he also maintains his own web site, which is used to trade DVDs and computer games with friends. He was initially won over to the Java programming language's approach to structured programming. From there, he became fascinated by servlets and JavaServer Pages, which he found far superior to the templating language he had previously used with Perl. But it was the feature-set of Tomcat that led Delagrange to the Jakarta Project. "Tomcat is just so easy to use and install compared to a lot of the other J2EE engines out there," he says. "And it has nice features like automatic class reloading." Delagrange slowly worked his way up within the Jakarta Project in terms of involvement and responsibility. He had been writing scriptlets and JavaBeans to display and update the data on his site. But it increasingly seemed that a set of custom tags would better serve his needs. "I began exploring custom tag library authoring," he says, "and in less than a week I was able to learn the syntax and complete a set of tags that met my needs." He eventually settled on a simplified abstraction of the JDBC API. "My JSPs were transformed as a result," he says. "Adding new database features to the site became almost trivial. From here, Delagrange began to explore the Jakarta Taglibs Project. "I was struck by the Request and Session tag libraries," he says. "But I noticed that the tags addressed only two of the major servlet scopes, while the other two, Page and Application, had no tag libraries." Delagrange decided to create Page and Application tag libraries for use in his own applications, but he also submitted them to the Taglibs Project. This led to his being nominated for committer status. "I was nominated by the original author of the Request and Session tag libraries," he says. "Then I was accepted by vote of the other committers."
At this point, Delagrange submitted his JDBC tag library to the project. And here, he has awarded particularly high marks for the Jakarta Project's open-source development paradigm. "Even though it was a useful tag library to begin with," he says, "I can't overemphasize how much it improved through the discussions and contributions of the Taglib Project. Features that were a direct result of the discussions, debates, and inspirations at Jakarta include: JNDI support, DataSource support, PreparedStatement support, SQL-escaping tags, various conditional logic tags (for dealing with nulls and empty ResultSets and so on.), internationalization of time and number formats, and more." While three other developers, Glenn Nielsen, Rich Catlett, and Marius Scurtescu, directly contributed to the code, well over a dozen people contributed comments and criticisms to the JDBC tag library. "I think that open-source development sparks a kind of creativity that other techniques cannot match," says Delagrange. "When code is subjected to a great deal of peer review, it just tends to be more comprehensive." Another recently released Jakarta taglib is Scrape, which, as its name implies, provides tags useful in extracting content from web documents, and displaying them in JSPs. Stock quotes, for example, can be extracted from a financial site, and then displayed within a user JSP. The Scrape taglib's two committers are Glenn Nielsen, UNIX Programming Coordinator for the Missouri Research and Education Network (MOREnet), and Rich Catlett, a part-time student programmer for MOREnet, and recent graduate of the University of Missouri. "MOREnet is part of the University of Missouri system," says Nielsen, "and acts as the ISP for the state of Missouri, for K-12 schools, colleges, libraries, and state agencies. We administer Internet servers that provide a wide range of services. Some of that is web hosting." As a result, MOREnet had begun to explore better ways of allowing its customers to publish dynamic content. "We need to target a wide variety of skill levels," says Nielsen. "And we saw JSPs as the way that we could most easily push out the ability to do dynamic content to our customers." Like most members of the Jakarta Taglibs Project, Nielsen came to Jakarta via a serendipitous path. "Last spring, when we were looking at servlet containers," he says, "we looked at four or five of them. But none of them had a means by which to implement security." After speaking to a number of vendors, Nielsen found security rather low on their list of priorities. Then, at ApacheCon, he spoke to several Jakarta Tomcat developers. "They had already identified security as something that they wanted to implement," says Nielsen. "So ultimately, I ended up implementing the security manager for Tomcat." From there, Nielsen began exploring tag libraries. This was in the spring of 2000, not long after the custom tag library spec was released. As a result, there were not many taglibs to choose from. Meanwhile, Nielsen began exploring various turnkey applications for MOREnet customers, among them, an open-source message board that used JSPs, but with the Java code embedded as scriptlets. "I realized around that time," says Nielsen, "that it would be nice to have some fundamental tag libraries that you could build on top of. That's when I wrote and contributed to the Request, Response, and Session tag libraries." As a result of that work, Nielsen next began to look toward offering a tag library directed at extracting information from other sites. Together, Nielsen and Catlett set about developing the Scrape tag library. "I did a lot of the actual development work on it," says Catlett, "but Glenn provided the broad overview and general direction to the work." And here again, there are high marks awarded to the Jakarta open-source development paradigm. "I think it works very well," says Nielsen, "because you can get a broad range of perspectives and techniques for--not only how to structure the attributes in your tags, for the people who will be using them--but how to design the actual Java code. So you end up with the interfaces to the tags that the user sees, and the underlying code, being a great deal better because of the interaction between the different developers." "When you're developing something," adds Catlett, "you can't possibly think of every need or use that might arise. But in open-source, the code's out there being actively discussed by a broad range of developers." The Scrape library offers a great deal of power and elegance within a relatively small tag set. It employs an internal cache such that users don't have to constantly go to the remote site in order to gather data. Depending upon the update interval that's been specified (a background thread), the taglib can decide whether it needs to reaccess the site, or whether it can simply use its cached data. "I think the Scrape library really shows how you can have a very simple interface for the web publisher to use," says Nielsen, "but that hides very complex operations behind it." The various taglib developers at Jakarta often also end up cross-pollinating with one another across libraries. "When Morgan Delagrange was working on his JDBC library," says Nielsen, "we had the idea to add the ability to use a JNDI named data source. We suggested that on the developer list, and convinced Morgan that it was a good idea. And he decided that, since it was something we were already working with, that it would be better if we just implemented it."
The FutureThe Jakarta Taglibs Project is currently in a growth phase, transitioning from the informal infrastructure of a technology incubator, to the more mature update and release procedures found in larger Jakarta projects. "When we release a tag library, we currently just post a link on the home page and send notification to the user mailing list," says Delagrange. "Unlike some of the other projects on Jakarta, we don't have stable releases yet. It's basically just daily builds. We make a very strong effort to be sure those builds are good, in terms of rigorous testing," he says, "but we don't have formal unit testing, and we don't have a formal release process. As a result, we're in active discussion on the list now as to how to best do that." In order to meet the challenges inherent in this more mature phase, however, the project needs to continue to attract new participants. "We're looking for more volunteers to participate, with even greater involvement," says Delisle. "We need everyone in the community to help move the Taglibs project to the next level, where it will serve as a mature development and distribution center for commercial-quality open source JSP tag libraries."
Useful Links
The Jakarta Taglibs Project
About the AuthorSteve Meloan, frequent contributor to the JDC, and java.sun.com, is a journalist, and former software developer. His work has appeared in Wired, Rolling Stone, BUZZ, San Francisco Examiner, ZDTV's "The Site," and American Cybercast's "The Pyramid." | |||||||||||||
Oracle is reviewing the Sun product roadmap and will provide guidance to customers in accordance with Oracle's standard product communication policies. Any resulting features and timing of release of such features as determined by Oracle's review of roadmaps, are at the sole discretion of Oracle. All product roadmap information, whether communicated by Sun Microsystems or by Oracle, does not represent a commitment to deliver any material, code, or functionality, and should not be relied upon in making purchasing decisions. It is intended for information purposes only, and may not be incorporated into any contract.
|
| ||||||||||||