The JSP Standard Tag Library (JSTL) is a new standard under the Java Community Process. JSTL 1.0 was finalized at the end of May 2002, and its reference implementation was released as part of Sun's Web Services Developer Pack (WDSP) earlier this month. The goal of JSTL 1.0 is to simplify the development of JSP pages by standardizing tags for the following tasks: - control flow (iteration, conditional logic, and error handling) - URL management (session encoding, cross-context imports, etc.) - text formatting and internationalization (i18n) - XML manipulation (with XPath) - database access (via JDBC) JSTL also offers an expression language for accessing scoped attributes, request parameters, and other data. (This expression language is planned to be the basis of a core addition to JSP 2.0.) Using JSTL tags and the new expression language, you can often avoid scripting elements ("scriptlets" and scripting expressions) in your pages. JSTL works with a number of different models for web development. Users of a "model 2" approach will probably appreciate JSTL's expression language and core tags for control flow; prototypers and developers of small applications may appreciate its SQL tags. Personally, I find JSTL's XML tags to offer a convenient, powerful alternative to XSLT for many common XML-manipulation tasks. And JSTL also offers an API for programmers who wish to configure JSTL and expose data for their JSP pages. This message serves to announce that the Apache Jakarta Taglibs project has just released version 1.0 of its "Standard Taglib," an implementation of JSTL. (The implementation at Jakarta Taglibs is also the basis for Sun's reference implementation of JSTL.) You can download the 1.0 release of the Standard Taglib at http://jakarta.apache.org/builds/jakarta-taglibs/releases/standard/ The Standard Taglib requires JSP 1.2; it has been tested with Tomcat 4.0.4. (Earlier versions of Tomcat may have trouble loading the JAXP 1.2 classes included with our distribution, so I recommend using Tomcat 4.0.4. A set of older XML files is available from the URL above if you want to use an older version of Tomcat.) I'm happy to answer questions that you have about JSTL; for detailed discussion, you might be interested in joining the 'taglibs-user' mailing list at Jakarta; see http://jakarta.apache.org/site/mail.html for instructions on how to do so. For general information about JSTL, as well as a link to the formal specification, pointers to upcoming books on JSTL, and current articles, see http://java.sun.com/products/jsp/jstl/ If you have any comments for future versions of JSTL, you can submit them to our expert group by mailing email@example.com. Enjoy, -- Shawn Bayern JSTL reference implementation lead Author, "JSTL in Action" http://www.manning.com/bayern (July 2002) [ June 21, 2002: Message edited by: Shawn Bayern ]
Hi, Thanks for yr info and its gr8 news.I would like to get a clarification from u. I have a collection of collection.Each collection contains four records .So using this data I can display a table with four columns.I can use "for loop" and scriplets to implement the same in JSP. I want to know how can I do the same with taglib or JSTL.I know to do with one column(one <td> . Will be very help if u give an example for forEach tag. Thanks in advance, A.Umar
Sun Certified Java Programmer for Java 2.0 (93%) <p>----Winners always make the learning a habit
posted 17 years ago
Originally posted by umar hathab: Hi, Thanks for yr info and its gr8 news.I would like to get a clarification from u. I have a collection of collection.Each collection contains four records .So using this data I can display a table with four columns.I can use "for loop" and scriplets to implement the same in JSP. I want to know how can I do the same with taglib or JSTL.I know to do with one column(one <td> ;) . Will be very help if u give an example for forEach tag.
Effectively, multi-dimensional looping works the same in JSTL and in Java. That is, first you loop over the outer dimension, then the inner one. My book has a number of examples of this, since it's often necessary when printing an HTML table for a database result set. As a simple example, suppose you have a variable named 'a' which is a collection (say, for the sake of argument, an array) that contains four collections: a, a, a, and a. To print a two-dimensional table for this collection and its sub-collections, you could write something like this:
Hope that helps! The examples to my book are available for free from Manning's site at http://www.manning.com/bayern (just click "Source code" on the left), in case you want more examples. (They're bundled with a JSTL implementation and Tomcat to make it easy to get up and running quickly.) -- Shawn Bayern "JSTL in Action" http://www.jstlbook.com (coming in July 2002 from Manning Publications) [ June 22, 2002: Message edited by: Shawn Bayern ]