Literal Data and Named Variables
This section describes literal data and named variables used in EL expressions. 5 types of literal data are supported: Boolean, Integer, Floating Point Number, String, and Null.
As in all computer language, expression starts with literal data and variables.
EL expression language supports 5 types of literal data:
- Boolean - true and false. Same as Java boolean.
- Integer - like 9999, -3, and 0. Same as Java long.
- Floating point number - like, 1.0, 3.14159, and -1.0e-3. Same as Java double.
- String - like, 'USA', "USA", or 'Herong\'s notes'. Close to Java String.
- Null - null. Same as Java null.
The literal data rules are easy to understand, with a couple of exceptions:
- No literal data for character data type.
- String can be quoted by single quote (').
Named variables are coming from two sources:
- Variables defined by the JSTL "set" tag.
- Variables provided as attributes in the pageContext object prepared by other
server side codes, like useBean and scriptlet JSP elements.
Variables provided as pageContext attributes will have their original Java types, like
int, float, char, or Object. But all EL operations will be carried out in
one of the 5 types of literal data. Operators of other types will be converted
before the operation.
Type conversion rules:
- To string - Using the Java rules, except that null will be converted to "".
- To boolean - Using the Java rules, except that null or "" will be converted to false.
- To integer - Using the Java rules, except that null or "" will be converted to 0.
- To floating point number - Using the Java rules, except that null or "" will be converted to 0.0.
- To object - Using the Java rules, except that "" will be converted to null.
Last update: 2012.
Table of Contents
About This Book
JSP (JavaServer Pages) Overview
Tomcat 7 Installation on Windows Systems
JSP Scripting Elements
Java Servlet Introduction
JSP Implicit Objects
Syntax of JSP Pages and JSP Documents
JSP Application Session
Managing Cookies in JSP Pages
JavaBean Objects and "useBean" Action Elements
Managing HTTP Response Header Lines
Non-ASCII Characters Support in JSP Pages
Performance of JSP Pages
►EL (Expression Language)
What is EL (Expression Language)?
EL Expression Types and Usage
►Literal Data and Named Variables
Basic Operators and Operations
Predefined Implicit Objects
Collection Elements and Object Properties
Expression Examples in Static Text
Expression Examples in Static Text - Result
EL Variables Are pageContext Attributes
Overview of JSTL (JSP Standard Tag Libraries)
JSTL Core Library
JSP Custom Tags
JSP Java Tag Interface
Custom Tag Attributes
Multiple Tags Working Together
File Upload Test Application
PDF Printing Version