Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Example Analysis of Standard tag Library in JSP

2025-01-16 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/02 Report--

This article mainly shows you the "sample analysis of the standard tag library in JSP", which is easy to understand and well-organized. I hope it can help you solve your doubts. Let the editor lead you to study and study the "sample analysis of the standard tag library in JSP".

Introduction to JSP 1. Code example of a jsp page without JSTL

Example 1. Implement conditional content through scriptlet

(scriptlet: contains a valid program segment. Any text, HTML tags, JSP elements must be outside of scriptlet)

Welcome, member!

< /p>

Welcome, guest!

< /p>

Fixing such problems usually requires considerable programming experience. Although JSP is usually developed and maintained by designers who are well versed in page layout and graphic design, programmers are required to intervene when there are problems with scripting elements on the same page. This situation shares the responsibility for the code in a single file to multiple people, making it a cumbersome task to develop, debug, and enhance such JSP pages. By wrapping common functions into a standard collection of custom tag libraries, JSTL enables JSP authors to reduce the need for scripting elements, even without them, and to avoid associated maintenance costs.

Introduction to JSP II. Introduction to JSTL 1.0

JSTL 1.0 was released in June 2002 and consists of four custom tag libraries (core, format, xml, and sql) and a pair of generic tag library validators (ScriptFreeTLV and PermittedTaglibsTLV).

The core tag library provides custom actions to manage data through scoped variables, and to perform iterations and conditional actions on page content. It also provides tags for generating and manipulating URL.

The format tag library defines the operations used to format data, especially numbers and dates. It also supports the internationalization of JSP pages using localized resource bundles.

The xml library contains tags that manipulate data represented by XML

The sql library defines how to query a relational database.

Introduction to JSP III. Expression language (EL)

The format of the EL expression is delimited by a dollar sign ($) and the content is included in curly braces ({}).

Example 2. Describes the JSTL operation of EL expression delimiters

< c:out value="${user.firstName}"/>

Example 3. Combine static text and multiple EL expressions to specify dynamic attribute values

< c:out value="Hello ${user.firstName} ${user.lastName}"/>

Introduction to JSP IV. Taglib pseudo instruction

Example 4. Taglib directive for the EL version of the JSTL core library

< %@ taglib uri="http://java.sun.com/jstl/core" prefix="c" %>

Introduction to JSP V. Variable tag

The syntax for this operation is shown in example 5, where the var attribute specifies the name of the variable, the scope attribute indicates the scope in which the variable resides, and the value attribute specifies the value assigned to the variable. If the specified variable already exists, simply assign the specified value to it. If it does not exist, create a new scoped variable and initialize it with that value.

Example 5.

< c:set>

Syntax of the operation

< c:set var="name" scope="scope" value="${user.firstName}"/>

The above is all the contents of the article "sample Analysis of Standard tag Libraries in JSP". Thank you for reading! I believe we all have a certain understanding, hope to share the content to help you, if you want to learn more knowledge, welcome to follow the industry information channel!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report