Using JSTL to achieve rapid development
In this article, I will introduce you to JSP-based and flexible techniques, which is JSTL.JSTL is called Java Server Pages Standard Tag Library. Although JSP has become very popular, JSTL is based on SQL database based on SQL database Simple, fast inner rear development is not extensive. Once you have learned JSTL, you will learn about its advantages and discover in your daily work as a programmer, it has been applied to many aspects. I am assuing that you are familiar with HTML, you can understand the basic SQL statements, and the basics of JSP. These knowledge should be involved in the following content. JSTL is a collection of tag library that has been standardized. She supports iteration, condition, XML document parsing, internationalization, and functions of using SQL and database interaction. At first, JSTL specification has been perfectred by JSR # 52 under JAVA Community Process Program, "JCP shoulder the development of Java technology" - the official website is evaluated. As an open organization, JCP has absorbed official membership and informal members. JCP has played an important leading role in the formation and development of Java technical specifications. JSTL mainly includes four basic partial tags: Core, XML, internationalization, and support for SQL. Since this article is primarily learned by the application of the SQL part, our article only introduces some basic functions of the Core and SQL tag libraries.
This technology is simple and powerful, enough to PHP, ColdFusion is higher. He has sufficient capacity in expanding the Java application, which does not include large-scalely upgraded web applications, for only the simple home page There is no problem as the web program. This allows you to avoid integration of XML often considered XML when you set up a site, and connect to the database. As I mentioned just mentioned, the key point of JSTL is simple and easy. Also, that is JSTL, based on JSP, which allows us to use all Java technology, this is necessary to remember. Before you start, we need to figure out how to run JSTL. Because we are based on JSP technology, we need a container that can compile JSP, here we use free JSP containers: Tomcat (http: //jakarta.apache. ORG / Tomcat / Index.html). As for how to install this product, it has exceeded the scope described in this article. There is no doubt that this software product is now very popular, and there are many documentation on how to install. Here, you have installed and successfully configured this container, you only need to install the JSTL to run the required file, it can download http://jakarta.apache.org/taglibs/doc/standard-doc/intro. HTML You don't need to install it, just need to put it .jar files in the web-inf / lib directory of your application, I will specify what to do later.
Because we have to run programs on a database that supports standard SQL, you need to have a database on your computer. There are many kinds of databases, here I have selected MySQL. The reason why I chose his choice is to first, we need to show the role of JSTL to construct a simple and fast application field, and can also compare with PHP mysql that is in the dominant position in this area; second point is MySQL is available for free download and include a JDBC driver for Java. In short, in order to use the following example, you need to download a mysql server (http://www.mysql.com/products/mysql/index.html; mysql connection / J jdbc driver http://www.mysql.com/products/connector-j/index.html; there is a mysql control center http://www.mysql.com/products/connector-j/index.html ), This product allows you to manage the MySQL database file very easy to operate. After all download is complete, you need to install MySQL and MySQL Control Center. There is also the JDBC driver of mysql needs to be placed in the / web-inf / lib directory in your web application. Before creating the program code, you need to create and fill in the database table. The subject matter on this aspect is also quite extensive, how to operate more than the scope of this article. Here I recommend you to a visual management tool I mentioned above. You can use him to create a test user, database, and a test table for running the program, and fill in a number of records. With regard to the login name and password database name, these configuration environment parameters, you should remember them, and you need to apply to our code later.
Now, you can prepare to create your first JSTL application. It needs us to do something below:
The entire instance code includes two files hello.jsp and continue.jsphello.jsp files Allow you to enter the database name, login name, login password, database table name. Continue.jsp: Accept data information in Hello.JSP and connect the database and perform a SELECT request to the table in the database.
Below is all of this system all code files, I will explain one by one. These codes are quite simple, for the structure of the code, I believe that you can understand even if you don't have my explanation.
1: 2: 3:
4: