Easy Development with the JSP Standard Tag Library (JSTL)
In this article, I will introduce you to interesting and flexible technology based on JSP, called JSTL. JSTL stands for Java Server Pages Standard Tag Library. Although JSP has already become very popular, it is not widely used in the development of easy, rapidly-done front-ends with SQL databases. Once you get to know JSTL, you will understand its advantages and will see numerous ways how it can be used in your everyday programmer's life. I assume that you are familiar with HTML, the basics of SQL requests, and JSP; however, I will describe everything along the way.
JSTL is a standardized collection of tag libraries for supporting iterations and conditionals, XML documents parsing, internationalization, and database access using SQL. Originally, the JSTL specification was being developed by the JSR #52 under the Java Community Process program (JCP). "The JCP holds the responsibility for the development of Java technology."—claims the official site. As an open, inclusive organization of active members and non-member public input, JCP primarily guides the development and approval of Java technical specifications. There are four basic tag libraries: core, XML, internationalization, and SQL support. As our goal is to quickly study opportunities for JSTL to work with SQL, in this article we shall consider only the basic functions of the libraries' core and SQL.
This technology is simple and yet powerful enough to be a worthy competitor PHP and ColdFusion. It has the capability to really expand Java's area of usage, not only for large, scalable Web applications, but also for simple "homepages." This would allow you to create sites without ceremony integrating them with XML documents and linking them with databases. As I have already noted, its plus is its simplicity of use. It is necessary to remember that it is being constructed on JSP. JSTL will allow us to use the power of all Java technologies.
To begin with, let's talk about how we will be able to run JSTL. JSTL builds on JSP technology; that's why running it requires any JSP-compatible container. For this purpose, we can use the free JSP container called Tomcat (http://jakarta.apache.org/tomcat/index.html). An explanation of installing this product goes beyond this article. Needless to say, this software is very popular and there is a lot of documentation on this topic. I will assume that you have already installed and configured the container, so you will need to install an implementation of JSTL. It can be downloaded from its Web site at http://jakarta.apache.org/taglibs/doc/standard-doc/intro.html.
|If you have difficulty understanding what such .JAR files are, it is possible that you are familiar with Java only superficially. I would advise you from the beginning to learn the basics of Web programming in Java; nevertheless, I shall describe the meaning of .JAR. JAR is an archive in which there are classes, all written and compiled in p-code, stored to facilitate their use and mobility. Thus, in JAR's Connector/J, you will find classes for MySQL JDBC driver, and in JSTL's you will find its branch of classes.|
You do not really need to install it; you can just include the .JAR files from the JSTL package into your /WEB-INF/lib/ directory. But, hold on for a while — I will show you how to do that a bit later.
Because we will work with SQL databases, you need to have any one of them installed. There is a wide range of different databases, but in this article MySQL is used because for a few reasons. First of all, we are showing you how JSTL can be helpful for creating easy and fast applications in the area where PHP and MySQL dominate. Secondly, MySQL can be freely downloaded and has a JDBC driver for Java. In summary, to use our examples below, you need to download MySQL server (http://www.mysql.com/products/mysql/index.html), the MySQL Connector/J JDBC driver (http://www.mysql.com/products/connector-j/index.html), and MySQL Control Center (http://www.mysql.com/products/connector-j/index.html). These will let you work with your databases and administer them more easily. Once downloaded, you will need to install the server and control center. Again, your .JAR JDBC driver will need to be included into your /WEB-INF/lib/ directory.
Page 1 of 2