js| Process | Web page overview
The release of the Java Server Pages (JSP) standard tag Library (JSTL) is a significant advance for jsp/servlet developers. With an expression language (EL) and a set of four powerful, easy to learn standard tag libraries, JSTL is highly likely to become the main way to implement a dynamic, java-based site soon.
The introduction of the JSP servlet in 1996 made Java a reasonable choice for dynamic web development. The resulting Java Server Page (JSP) is a logical evolutionary step toward a fast, Maintainable Java Web page implementation, followed by JSP markup support. But the release of the 2002 medium-term JSTL (JSP standard tag Library) is the most important step to further accelerate and simplify the development process.
In this article, I explain the features of Jstl, and also cover everything you need to start jstl. Let's say you have a basic understanding of Java, JSP, XML, and installing a Web container. If you are unfamiliar with these topics, you can browse the background reference in http://www.javaworld.com/javaworld/jw-02-2003/jw-0228-jstl.html #resources #resources. In the following elaboration, assume that you have knowledge of XML and SQL.
Install JSTL Support
For our Jstl installation example, we use Tomcat 4.1 (although any servlet container that supports servlet 2.3 and JSP1.2 instructions should work). First, you download Tomcat 4.1 and follow the instructions to install it (note: Jstl requires a JSP1.2 web container).
Start Tomcat with the TOMCAT4 start program and run the index.html page to make sure that Tomcat is active and running well.
Next, install JSTL support, you can download Jstl support from the Jakarta site, (http://www.javaworld.com/javaworld/jw-02-2003/jw-0228-jstl.html? #resources #resources) and follow these steps:
1. Download Jstl Retrieve, extract/Tuodang the file from the Jakarta site. (http://www.javaworld.com/javaworld/jw-02-2003/jw-0228-jstl.html #resources)
2. Copy the jar files you have unpacked into your common/lib to your Tomcat installation path (although our project does not require all of the jar files); This makes the Jstl file applicable to any Web application you have.
3. For any Web application you want to use Jstl, copy the. tld file to the Web-inf directory of your Web application.
4. For your JSTL Web application, edit the Web.xml and add the following input:
<taglib> <taglib-uri>http://java.sun.com/jstl/fmt</taglib-uri> <taglib-location >/WEB-INF/fmt.tld</taglib-location> </taglib> <taglib> <taglib-uri>http ://java.sun.com/jstl/core</taglib-uri> <taglib-location>/WEB-INF/c.tld</taglib-location> </taglib> <taglib> <taglib-uri>http://java.sun.com/jstl/sql</taglib-uri > <taglib-location>/WEB-INF/sql.tld</taglib-location> </taglib> <taglib > <taglib-uri>http://java.sun.com/jstl/x</taglib-uri> <taglib-location>/web-inf /x.tld</taglib-location> </taglib>
These inputs allow your Web application to use the expression language (EL) version of the JSTL tag library. The location of these inputs is related! If you're not sure where to put them, the authoritative guidance on the Web.xml options and order is defined in the document type definition (DTD): Http://java.sun.com/j2ee/dtds/web-app_2_2.dtd.
5. When you create a JSP page that uses JSTL, enter it into the home directory of your Web application, just like any other JSP and HTML page. You can name the page arbitrarily, but it must have a. jsp extension.
Basic principle
First, all Jstl are JSP pages, Jstl is just a superset of JSP functionality.
Again, all the JSTL tags are valid XML. This means that if you use content other than Jstl tags as temporary text (usually HTML), the remaining JSTL tags must be interpreted as legitimate XML. Here are some implicit rules that require most of the XML syntax to be correct.
JSTL provides a set of four standard tag libraries (core core, Internationalization/format international standardization/format, XML and SQL) and supports El. The basic design of Jstl and El is to simplify web page development and implementation.
In this article, we follow the naming rules for the JSTL specification and take the JSTL tag as an action. A jstl tag corresponds to an action; the call action explicitly reminds us that they add dynamic behavior to an additional static page.
There are two versions of the JSTL tag Library: A method that you used to insert a JSP expression, such as <%= ...%>, and the other uses a jstl el. I'll discuss the El Support in Jstl later.
El Support
To understand the current state of Jstl on El Support, let's examine how the relevant instructions are handled. Java Specification request (JSR) Expert Group members decide: For some reason, the El specification description should be part of the JSP specification, not the JSTL specification. El Complete instructions become part of the JSP2.0. Since JSTL1.0 was completed before JSP1.3, the Jstl author had to make a reasonable guess about the implementation of El Support for JSTL1.0 (the result could be quite good). A JSTL maintenance version will be consistent with the JSP1.3 specification and a number of revisions have been made to the Jstl maintenance version to make El Suitable for JSP1.3 instructions.
The El profile described in this article may be slightly altered in the upcoming JSTL release, but any changes are minor.
El for simple syntax defines a powerful set of languages that are easy to learn. It blends some of the styles of the JavaScript language with the better part of the Perl language. El expressions, which integrate the JSTL tags from four standard tag libraries, provide a huge, flexible set of properties.
All El expressions are enclosed by ${}. An expression in Jstl is always part of the value of a property in the Jstl tag. An expression can be part of a property or merged and embedded into a string's direct volume. The Jstl property can also contain a simple string of direct quantities. In the next jstl, we illustrate each case in a c:out action from the core library, which sends its value attribute values to the JSP output:
<c:out value= "${anexpression}"/><c:out value= "literaltext${anexpression}${anotherexpression}"/><c : Out value= "LiteralText"/>
El also defines a set of rules used to force the conversion of values in an expression to the type corresponding to the context. We do not discuss these rules in detail here; however, its approach is very similar to the way it is defined in Perl (as in the Perl language, which is certainly working well, but, occasionally, it may not be the kind of result you want, but you can accept).
El provides support for accessing object properties, collection elements, a set of hidden objects, and the use of related, logical, and arithmetic operators. For indexed properties, including arrays and java.util.List classes, elements can be accessed using the following syntax:
${alist[4]}${alist[somevariable]}
The JavaBean property and the Java.util.Map element (which represents a series of name/value pairs) can be obtained using one of the following methods. In the first two expressions below, we can access a property named Aproperty in the JavaBean language or access to a map entity with a keyword aproperty. In the third expression (note: I have omitted quotes), we access an element within AnObject using a name stored in the variable avariablecontainingpropertyname:
${anobject.aproperty}${anobject["Apropertyname"]}${anobject[ Avariablecontainingpropertyname]}
defines a number of hidden variables in el:
PageContext: Pagecontex for this page T objects
Pagescope, Requestscope, Sessionscope, and Applicationscope: These are map sets that map each of these ranges to values.
param and paramvalues: Parameters passed with page access, as in JSP
Header and Headervalues: headers passed with page requests, as in JSP
Cookies : The map map cookie program on a particular cookie object
El defines the full set of operators that you are familiar with in Java. The algorithm operators include +,-, *,/(or div), and% (or mod). The related operators include = =,! =, <, >, <=, >=, which correspond to EQ, NE, lt, GT, le, and GE respectively. I don't want to elaborate on these operators because they can all explain themselves.