Home  >  Article  >  Java  >  What is the use of EL expression in jsp?

What is the use of EL expression in jsp?

青灯夜游
青灯夜游Original
2019-05-31 17:46:363686browse

What is the use of EL expression in jsp?

JSP EL language definition

E L (Expression Language) Purpose: To make JSP easier to write.

The Expression Language is inspired by the ECMAScript and XPath Expression Language and provides a way to simplify expressions in JSP. It is a simple language based on the available namespace (PageContext attribute), nested properties and accessors to collections, operators (arithmetic, relational and logical), mapping to static methods in Java classes. extension functions and a set of implicit objects.

EL provides the ability to use runtime expressions outside the scope of JSP scripting elements. A scripting element is an element in a page that can be used to embed Java code in a JSP file. They are typically used for object manipulation and performing calculations that affect what is generated. JSP 2.0 adds EL expressions as a scripting element.

What is the use of EL expressions in jsp?

1. Obtain data:

EL expressions are mainly used to replace script expressions in JSP pages to retrieve java objects and obtain data from various types of web domains. . (Objects in a certain web domain, access Javabean properties, access list collections, access map collections, access arrays)

2. Execute operations:

Use EL expressions to perform operations on the JSP page Perform some basic relational operations, logical operations and arithmetic operations to complete some simple logical operations in the JSP page.

${user==null}

3. Obtain common objects in web development

EL expressions define some implicit objects. Using these implicit objects, web developers can easily obtain references to common web objects. To obtain the data in these objects.

4. Call Java methods

EL expressions allow users to develop custom EL functions to call Java class methods through EL expressions in JSP pages.

Use EL expression to obtain data syntax: "${identifier}" When the EL expression statement is executed, the pageContext.findAttribute method will be called, using the identifier as the keyword, respectively from page, requestsession, application Search for the corresponding object in the four fields, and return the corresponding object if found. If not found, return "" (note, not null, but an empty string).

Example:${user}

The above is the detailed content of What is the use of EL expression in jsp?. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn