First knowledge of jstl

Source: Internet
Author: User
Tags tld

When I first got started with the jstl label library, I felt it was powerful. During development, we will see that JSP has a lot of dynamic content logic which needs to be implemented using Java code. The jstl tag library can solve these problems well, so that jsp can be reduced, page developers no longer worry about learning java. They can use tags to complete JSP development. With jstl, the development efficiency is improved and the readability and maintainability of the program are improved.

 

Jstl stands for JSP standard tag Library (JSP standard tag Library), which is a continuously improved open-source JSP tag library maintained by the Apache Jakarta team; in fact, it can be seen as a set of tag libraries formed by custom tags Based on XML syntax, providing five standard tag libraries (core, internationalization/format (International Standard/format), XML, SQL, and function) and supports el.


Among them, the core tag library of jstl provides a set of common functions of all JSP pages; the SQL tag Library provides access to the database; in addition, the internationalization/format tag Library provides international (i18n) Tag sets and related tag sets, such as numbers and dates, to process the internationalization and formatting of data display; the XML tag Library provides support for the XML language, and the function tag Library provides support for functions. From this we can see that jstl and El simplify JSP web development with great advantages.

 

Jstl has the following three installation and configuration steps:

1) copy the jstl implementation library file jstl. jar and standard. jar and the tag library description folder TLD to the Tomcat webapps WEB-INF.


2) (the second step can not be configured) modify the web. XML (Web application configuration file), in which the corresponding to the five standard tag libraries are defined. the URI of the TLD (marking the library description file. For example, before using the core tag library, you must edit web. xml and add the following code to it:

<Taglib-Uri> http // java.sun.com/jsp/jstl/core

<Taglib-location>/WEB-INF/TLD/C. TLD


3) use the taglib tag library command at the beginning of the JSP page to specify the tag library to be used. For example, to use jstl core to mark the library, the taglib pseudocommand of El version is:

<% Taglib uri = http://java.sun.com/jsp/jstl/core "prefix =" C "%>

Where: C is the prefix name of the core tag Library (which can be specified by the user or prefix C agreed by the System), which is used when marking the library.

 

Finally, let's talk about the four major scopes: Page, request, session, and application ). The four objects can store and retrieve data through <JSP: usebean> in JSP. jstl extends this capability by providing additional operations for specifying and removing objects in these scopes. In addition, El provides built-in support for searching these objects as variables with limited scopes. To put it bluntly, jstl can also store and retrieve data in these four scopes.


A scope is the lifecycle of a certain State. A page only acts on the current page, and a request plays a role in forwarding, session is valid if your browser is disabled or the access interval does not exceed the server-defined inactivity time, and the application is a bit scary as long as your server is not active forever.

 

We don't need to go into details about the specific jstl usage here. It feels very simple, just like the use of the aspx control. That is to drag it directly. Now it is implemented using code.

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.