Use of EL expressions in JSP for instance parsing, and example jspel expressions

Source: Internet
Author: User

Use of EL expressions in JSP for instance parsing, and example jspel expressions

El operator:

<% @ Page language = "java" contentType = "text/html; charset = gb2312" %> <% @ page import = "java. SQL. *" %> <! DOCTYPE html> 

EL processing built-in objects:
The "." and "[]" symbols are used to access data.

${applicationScope.user.username}${applicationScope.user[0].username}${applicationScope.user["user-name"]}

[]

${applicationScope.user["data"]}

Storage-related built-in objects

<! DOCTYPE html> 

Input-related built-in objects

<! DOCTYPE html> 

Cookie built-in object

<! DOCTYPE html> 

Header built-in object

<! DOCTYPE html> 

InitParam built-in object: Get environment variables set in the web site

<% @ Page language = "java" contentType = "text/html; charset = gb2312" %> <! DOCTYPE html> 

PageContex built-in object
Used to obtain detailed information about user requests and pages

<% @ Page language = "java" contentType = "text/html; charset = gb2312" %> <! DOCTYPE html> 

EL accessors:
Use accessors to read data from JavaBean

Package com. javaweb. ch08; import java. util. *; // a simple JavaBean example public class Person {// name attribute private String name; // age attribute private int age; // sex attribute private String sex; // friends attribute private ArrayList friends; // The construction method without parameters: public Person () {}// custom Construction Method: public Person (String name, int age, String sex) {this. name = name; this. age = age; this. sex = sex;} // get the name attribute value public String getName () {return name;} // get the age attribute value public int getAge () {return age ;} // obtain the sex property value public String getSex () {return sex;} // set the name attribute public void setName (String name) {this. name = name;} // set the age attribute value public void setAge (int age) {this. age = age;} // set the property value of sex public void setSex (String sex) {this. sex = sex;} // set the value of friends to public void setFriends (ArrayList friends) {this. friends = friends;} // obtain the friends attribute value public ArrayList getFriends () {return friends ;}}
<% @ Page language = "java" contentType = "text/html; charset = gb2312" %> <% @ page import = "java. util. *, com. javaweb. ch08. * "%> <! DOCTYPE html> 

Use memory to read data in Map

<% @ Page language = "java" contentType = "text/html; charset = gb2312" %> <% @ page import = "java. util. *, com. javaweb. ch08. * "%> <! DOCTYPE html> 

Use memory to read data in the array

<% @ Page language = "java" contentType = "text/html; charset = gb2312" %> <% @ page import = "java. util. *, com. javaweb. ch08. * "%> <! DOCTYPE html> 

Complex applications of memory

<% @ Page language = "java" contentType = "text/html; charset = gb2312" %> <% @ page import = "java. util. *, com. javaweb. ch08. * "%> <! DOCTYPE html> 

Articles you may be interested in:
  • Solution for parsing EL expressions in JSP
  • Jsp el expressions
  • Jsp does not support EL expressions. Solution
  • Solve the problem that EL is not supported in jsp development.

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.