EL and JSTL. JSTL Sources https://jstl.java.net/

Slides:



Advertisements
Similar presentations
IF statement (i) Single statement. IF ( logical expression ) statement Example: read(*,*) a if (a. lt. 0) a = -a write(*,*) a Or read(*,*) a if (a < 0)
Advertisements

Types and Arithmetic Operators
Expression Language Lec Umair Javed©2006 Generating Dynamic Contents Technologies available  Servlets  JSP  JavaBeans  Custom Tags  Expression.
CS 355 – PROGRAMMING LANGUAGES Dr. X. Apply-to-all A functional form that takes a single function as a parameter and yields a list of values obtained.
Data Types in Java Data is the information that a program has to work with. Data is of different types. The type of a piece of data tells Java what can.
Expressions ► An expression can be a single variable, or can include a series of variables. If an expression includes multiple variables they are combined.
IntroductionIntroduction  Computer program: an ordered sequence of statements whose objective is to accomplish a task.  Programming: process of planning.
©2004 Brooks/Cole Chapter 2 Variables, Values and Operations.
CS320 Web and Internet Programming Java Beans and Expression Language (EL) Chengyu Sun California State University, Los Angeles.
1 Chapter 4 Language Fundamentals. 2 Identifiers Program parts such as packages, classes, and class members have names, which are formally known as identifiers.
CS320 Web and Internet Programming JSP Standard Tag Library (JSTL) Chengyu Sun California State University, Los Angeles.
0 Chap. 2. Types, Operators, and Expressions 2.1Variable Names 2.2Data Types and Sizes 2.3Constants 2.4Declarations Imperative Programming, B. Hirsbrunner,
The UNIVERSITY of NORTH CAROLINA at CHAPEL HILL Adrian Ilie COMP 14 Introduction to Programming Adrian Ilie June 27, 2005.
Primitive Types Java supports two kinds of types of values – objects, and – values of primitive data types variables store – either references to objects.
JavaScript, Third Edition
Performing Simple Calculations with C# Svetlin Nakov Telerik Corporation
Expressions & Assignments One of the original intentions of computer programs was the evaluation of mathematical expressions –languages would inherit much.
Intermediate JSP Matt Wheeler. Notes This is a training NOT a presentation If you have questions please ask them Prerequisites – Introduction to Java.
 Value, Variable and Data Type  Type Conversion  Arithmetic Expression Evaluation  Scope of variable.
Expressions creating information. topics  operators: precedence, associativity, parentheses, overloading  operands: side-effects, coercion  arithmetic,
Java Primitives The Smallest Building Blocks of the Language (corresponds with Chapter 2)
Chapter 2: Basic Elements of Java J ava P rogramming: From Problem Analysis to Program Design, From Problem Analysis to Program Design, Second Edition.
Chapter 2 part #4 Operator
2440: 211 Interactive Web Programming Expressions & Operators.
Chapter 3: Data Types and Operators JavaScript - Introductory.
Chapter 2 Basic Elements of Java. Chapter Objectives Become familiar with the basic components of a Java program, including methods, special symbols,
CHAPTER 2 PART #4 OPERATOR 2 nd semester King Saud University College of Applied studies and Community Service Csc 1101 By: Asma Alosaimi Edited.
CS320 Web and Internet Programming Java Beans and Expression Language (EL) Chengyu Sun California State University, Los Angeles.
CSI 3120, Expressions and assignment, page 1 Expressions and assignment Points for discussion Arithmetic expressions Overloading Logical expressions Assignment.
BUILDING JAVA PROGRAMS CHAPTER 2 PRIMITIVE DATA TYPES AND OPERATIONS.
Java Programming: From Problem Analysis to Program Design, 4e Chapter 2 Basic Elements of Java.
CompSci 100E 2.1 Java Basics - Expressions  Literals  A literal is a constant value also called a self-defining term  Possibilities: o Object: null,
Object-Oriented Program Development Using Java: A Class-Centered Approach, Enhanced Edition.
JSP Expression Language (EL) 25-Nov-15. JSP - E XPRESSION L ANGUAGE (EL) Introduction Expression Language was first introduced in JSTL 1.0 (JSP Standard.
Python Primer 1: Types and Operators © 2013 Goodrich, Tamassia, Goldwasser1Python Primer.
Data Types Declarations Expressions Data storage C++ Basics.
COMP Primitive and Class Types Yi Hong May 14, 2015.
Java Nuts and Bolts Variables and Data Types Operators Expressions Control Flow Statements Arrays and Strings.
Performing Simple Calculations with C# Telerik Corporation
CSM-Java Programming-I Spring,2005 Fundamental Data Types Lesson - 2.
ECE 103 Engineering Programming Chapter 4 Operators Herbert G. Mayer, PSU CS Status 6/19/2015 Initial content copied verbatim from ECE 103 material developed.
Java Programming: From Problem Analysis to Program Design, Second Edition 1 Lecture 1 Objectives  Become familiar with the basic components of a Java.
Operators. Perl has MANY operators. –Covered in Chapter 3 of Camel –perldoc perlop Many operators have numeric and string version –remember Perl will.
CS0007: Introduction to Computer Programming Primitive Data Types and Arithmetic Operations.
1Object-Oriented Program Development Using C++ Built-in Data Types Data type –Range of values –Set of operations on those values Literal: refers to acceptable.
ISBN Chapter 7 Expressions and Assignments Statements.
ECE 103 Engineering Programming Chapter 4 Operators Herbert G. Mayer, PSU Status 6/10/2016 Initial content copied verbatim from ECE 103 material developed.
Java Programming: Guided Learning with Early Objects Chapter 1 Basic Elements of Java.
CS520 Web Programming Servlet and JSP Review
Chapter 7: Expressions and Assignment Statements
2.0 FUNDAMENTALS OF JAVA PROGRAMMING LANGUAGE
Chapter 7: Expressions and Assignment Statements
Expressions An expression is a portion of a C++ statement that performs an evaluation of some kind Generally requires that a computation or data manipulation.
Multiple variables can be created in one declaration
Expressions & Assignments
Java Programming: From Problem Analysis to Program Design, 4e
Starting JavaProgramming
Chapter 8 JavaScript: Control Statements, Part 2
JSP Standard Tag Library
Chapter 2: Basic Elements of Java
CS320 Web and Internet Programming Expression Language (EL)
Python Primer 1: Types and Operators
Expressions An expression is a portion of a C++ statement that performs an evaluation of some kind Generally requires that a computation or data manipulation.
CS3220 Web and Internet Programming Expression Language (EL)
CS3220 Web and Internet Programming Expression Language (EL)
ENERGY 211 / CME 211 Lecture 5 October 1, 2008.
Operator King Saud University
Problem 1 Given n, calculate 2n
ICS 101 Lab 3 Hossain Arif ICS Dept
Presentation transcript:

EL and JSTL

JSTL Sources JSpec/ JSpec/

Syntax notation

Literal Expression To generate literal values that include the character sequence "${ " or “#{ “ or

Literals for boolean, integer, floating point, string, and null in an eval expression. Boolean - true and false Integer - As defined by the IntegerLiteral Floating point - As defined by the FloatingPointLiteral String - With single and double quotes - " is escaped as \", ' is escaped as \', and \ is escaped as \\. Null - null

Errors, Warnings, Default Values EL does not provide warnings, just default values and errors.

Arithmetic Operators Arithmetic is provided to act on integer (BigInteger and Long) and floating point (BigDecimal and Double) values. Addition: + Subtraction: - Multiplication: * Division: / and div Remainder (modulo): % and mod

Binary operators - A {+,-,*} B If A and B are null, return (Long)0 If A or B is a BigDecimal, coerce both to BigDecimal and then: If operator is +, return A.add(B) If operator is -, return A.subtract(B) If operator is *, return A.multiply(B) If A or B is a Float, Double, or String containing., e, or E: If A or B is BigInteger, coerce both A and B to BigDecimal and apply operator. Otherwise, coerce both A and B to Double and apply operator If A or B is BigInteger, coerce both to BigInteger and then: If operator is +, return A.add(B) If operator is -, return A.subtract(B) If operator is *, return A.multiply(B) Otherwise coerce both A and B to Long and apply operator If operator results in exception, error

Binary operator - A {/,div} B If A and B are null, return (Long)0 If A or B is a BigDecimal or a BigInteger, coerce both to BigDecimal and return A.divide(B, BigDecimal.ROUND_HALF_UP) Otherwise, coerce both A and B to Double and apply operator If operator results in exception, error

Binary operator - A {%,mod} B If A and B are null, return (Long)0 If A or B is a BigDecimal, Float, Double, or String containing., e, or E, coerce both A and B to Double and apply operator If A or B is a BigInteger, coerce both to BigInteger and return A.remainder(B). Otherwise coerce both A and B to Long and apply operator If operator results in exception, error

Unary minus operator - -A If A is null, return (Long)0 If A is a BigDecimal or BigInteger, return A.negate(). If A is a String: If A contains., e, or E, coerce to a Double and apply operator Otherwise, coerce to a Long and apply operator If operator results in exception, error If A is Byte, Short, Integer, Long, Float, Double Retain type, apply operator If operator results in exception, error Otherwise, error

Relational Operators The relational operators are: == and eq != and ne < and lt > and gt <= and le >= and ge

A {, =,lt,gt,le,ge} B If A==B, if operator is =, or ge return true. If A is null or B is null, return false If A or B is BigDecimal, coerce both A and B to BigDecimal and use the return value of A.compareTo(B). If A or B is Float or Double coerce both A and B to Double apply operator If A or B is BigInteger, coerce both A and B to BigInteger and use the return value of A.compareTo(B). If A or B is Byte, Short, Character, Integer, or Long coerce both A and B to Long and apply operator If A or B is String coerce both A and B to String, compare lexically If A is Comparable, then: If A.compareTo(B) throws exception, error. Otherwise use result of A.compareTo(B) If B is Comparable, then: If B.compareTo(A) throws exception, error. Otherwise use result of B.compareTo(A) Otherwise, error

A {==,!=,eq,ne} B If A==B, apply operator If A is null or B is null return false for == or eq, true for != or ne. If A or B is BigDecimal, coerce both A and B to BigDecimal and then: If operator is == or eq, return A.equals(B) If operator is != or ne, return !A.equals(B) If A or B is Float or Double coerce both A and B to Double, apply operator If A or B is BigInteger, coerce both A and B to BigInteger and then: If operator is == or eq, return A.equals(B) If operator is != or ne, return !A.equals(B) If A or B is Byte, Short, Character, Integer, or Long coerce both A and B to Long, apply operator If A or B is Boolean coerce both A and B to Boolean, apply operator If A or B is an enum, coerce both A and B to enum, apply operator If A or B is String coerce both A and B to String, compare lexically Otherwise if an error occurs while calling A.equals(B), error Otherwise, apply operator to result of A.equals(B)

Logical Operators The logical operators are: && and and || and or ! and not

Binary operator - A {&&,||,and,or} B Coerce both A and B to Boolean, apply operator The operator stops as soon as the expression can be determined, i.e., A and B and C and D – if B is false, then only A and B is evaluated. Unary not operator - {!,not} A Coerce A to Boolean, apply operator

Empty Operator - empty A The empty operator is a prefix operator that can be used to determine if a value is null or empty. To evaluate empty A if A is null, return true Otherwise, if A is the empty string, then return true Otherwise, if A is an empty array, then return true Otherwise, if A is an empty Map, return true Otherwise, if A is an empty Collection, return true Otherwise return false

Conditional Operator - A ? B : C Evaluate B or C, depending on the result of the evaluation of A. Coerce A to Boolean: If A is true, evaluate and return B If A is false, evaluate and return C

Parentheses Parentheses can be used to change precedence, as in: ${(a*(b+c))}

Operator Precedence Highest to lowest, left-to-right. []. () - (unary) not ! Empty * / div % mod + - (binary) = lt gt le ge == != eq ne && and || or ? : Qualified functions with a namespace prefix have precedence over the operators. Thus the expression ${c?b:f()} is illegal because b:f() is being parsed as a qualified function instead of part of a conditional expression. As usual, () can be used to make the precedence explicit, e.g ${c?b:(f())}

Reserved Words The following words are reserved for the language and must not be used as identifiers. and eq gt true instanceof or ne le false empty not lt ge null div mod Note that many of these words are not in the language

Functions The EL has qualified functions, reusing the notion of qualification from XML namespaces (and attributes), XSL functions, and JSP custom actions. Functions are mapped to public static methods in Java classes. The full syntax is that of qualified n-ary functions: [ns:]f([a1[,a2[,...[,an]]]]) Where ns is the namespace prefix, f is the name of the function, and a is an argument.

Getting Request Parameters

Nested Properties

Operators

Automatic Type Conversion

Default Values

Required Prefixes

Summary

Represents the last alternative within a action

Subtag of and

fn:contains

fn:containsIgnoreCase

fn:endsWith

fn:escapeXml

fn:indexOf

fn:join

fn:length

fn:replace

fn:split

fn:startsWith

fn:substring

fn:substringAfter

fn:substringBefore

fn:toLowerCase

fn:toUpperCase

fn:trim