The core tag Library of the basic tutorial of Jstl tag Library (i)

Source: Internet
Author: User
Tags apache tomcat

    • JSTL Introduction

Java Server Pages standard tag Libray (JSTL): JSP standards Tag Library, which encapsulates the common Core functionality of JSP applications. JSTL supports common, structured tasks such as iterations, conditional judgments, XML document manipulation, internationalization tags, and SQL tags. In addition to these, it also provides a framework for using custom labels with integrated Jstl.

Jstl refers to the standard tag library, according to its function can be summed up into five categories:

    • Core Tag Library
    • XML Tag Library
    • Formatting tag Libraries
    • Database Tag Library
    • JSTL function Tag Library

    • Jstl Tag Library Installation

Apache Tomcat installs the JSTL library steps as follows:
Download the binary package (Jakarta-taglibs-standard-current.zip) from the standard tag Library of Apache.

    • Official:http://archive.apache.org/dist/jakarta/taglibs/standard/binaries/

Download the Jakarta-taglibs-standard-1.1.2.zip package and unzip it to jakarta-taglibs-standard-1.1.2/lib/ Two jar files under: Standard.jar and Jstl.jar files are copied to/web-inf/lib/.
Jstl can only be run on containers that support JSP1.2 and Servlet2.3 specifications.

    • Reasons to use the tag library
    1. Keep the program good readability. Page Write Java code is not easy to maintain and modify, the readability is very poor.
    2. Strong reusability. Jstl tags can be reused indefinitely.
    3. The idea of layering can be realized. Separates the business from the display.
    4. Scalability is good. Jstl tags can only be imported into the JSTL package when used.
    5. More standardized, follow the XML standard.
    6. Simplified page, beautiful page.


Core Tag Library

The core tag is the most commonly used jstl tag. In order to use the Jstl class library on a JSP page, the TAGLIB directive must be used in the following format : <% @taglib uri= "" prefix= "%>
Example: <% @taglib uri= "Http://java.sun.com/jsp/jstl/core" prefix= "C"%>
The prefix can be anything, and following the specification can make the code in the team more similar to those written by different people, so it is recommended to use a pre-designed prefix.





So let's take a look at the common General action commands (out tags, set tags,remove tags):

    • Out label

An out tag evaluates an expression and outputs the result to the current jspwriter. There are two forms of out syntax, subject content and no principal content:
For example:



Before JSP2.0, out tags are the easiest way to output domain-limited object values. After JSP2.0, you can safely use the EL expression unless you need to convert a value to character: ${x}

    • Set label

The following work can be done with the set tag:
① creates a string and a domain-limited variable that references the string
② create a restricted domain variable and reference one of the restricted domain variables that already exist
③ setting properties for domain-limited objects
If you create a domain variable with set, then the entire JSP page after that tag will be able to use that variable.
<c:set> Common Properties of the tag (store values in scope or assign values to variable properties in JavaBean)

This form allows JSP code to be included in the main content

    • Remove label

Use the Remove tag to remove the restricted domain variable with the following syntax:




If no range is specified, then all four ranges can be found to be deleted.

Note: The object referenced by the domain-limited variable is not deleted. Therefore, if another domain object is referencing the object, the object can still be accessed through another domain-limited object.


Write here, everyone to JSTL Core Tag Library General action command also know about, then next to explain the core Tag Library conditions Action command follow-up will for everyone, please pay attention to Shanghai still school java.

The core tag Library of the basic tutorial of Jstl tag Library (i)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.