EL (Expression Language)

Source: Internet
Author: User


The purpose of EL is to aid producing scriptless JSP pages

Syntax of EL in a JSP page :$ {expr}
You can escape the expression:
\ $ {Expr}

<Body>
<Form action = "el2.jsp">
Username: <input type = "text" name = "username">
Password: <input type = "submit" name = "password">
<Input type = "submit" value = "submit">
</Form>

<Body>
$ {Param. username}
$ {Param. password}
<! -- <% = Request. getParameter ("username") %> -->
</Body>

Beans within the namespace avaiable to the JSP can be accessed easily using EL.

Beans can be accessed by way of dot notation: $ {bean. attribute}

Beans can be located by searching through the scopes: page, request, session and application

Beans scope can be specified by preceding the bean name with the scope
$ {SessionScope. cust. fristName}

<% Session. setAttribute ("aa", "bb"); %>

$ {SessionScope. aa} <br>
<% = Session. getAttribute ("aa") %>

Implicit Object: Description

If the bean return an array, and element can specify its
Index using [] nation:
$ {ParamValues. fruit [2]}

Username: <input type = "text" name = "username">
<Input type = "text" name = "username">
<Input type = "text" name = "username">

$ {ParamValue. username [2]}

Example operation
${2 + 1*3}
User user = new User;
Session. setAttribute ("user", user );

 

$ {SessionScope. user. sex}
User user = (User) session. getAttribute ("user ");
String sex = user. getSex ();

$ {SessionScope. user. sex} equals $ {sessionScope. user ["sex"]}

TypeCast: $ {param. count + 20}

 

Related Article

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.