JSP Tutorials - Herong's Tutorial Examples
∟EL (Expression Language)
∟Expression Examples in Static Text - Result
This section provides output result of a tutorial example with different Rvalue expressions embedded in static text: literal data, variables, implicit objects, user defined objects, collection elements, object properties, nested properties.
Here is the output of my EL expression example JSP page, ExpExample.jspx:
EL Expression in Static Text Examples:
1. true
2. 2
3. 0.3333333333333333
4. 0.3333333333333333
5. false
6. Hi there!
7. message
10. GET
11.
12. GET
15. GET
16. GET
21. JSESSIONID
22. E5753AA9621203B3AC480E0E3891880D
23. javax.servlet.http.Cookie@1d60834
26. javax.servlet.http.Cookie@1d60834
30.
31.
34. true
35. false
36. false
37. 1152816698019
Do you have any surprises when you compare your guess with the output?
I have some explanations on the output to help you:
- Example 3 shows you that the result of integer operations is not converted back to integer.
- Example 5 confirms that null is converted to false.
- Example 7 shows you that value will not be converted back
to an identifier (variable name).
- Examples 10 and 12 show you two correct ways of accessing object properties.
- Examples 11 is not valid, because an expression is expected inside "[]"
and "method" without quotes is an identifier and it matches no existing objects
(variable names).
- Examples 13 and 14 have syntax errors, because the "." operator only takes
identifiers (names) as operands.
- Examples 15 and 16 are different ways of writing nested "." operations.
- Examples 24 and 25 have syntax errors, because "0" is not allowed an identifier.
- Examples 30 and 31 tell us that variables declared in scripting elements
are not available to EL expression.
- Example 32 used to used in previous releases of JSP.
But it is not working in JSP 2.1. I guess "class" and "name" are
not considered as properties, event Java offers Object.getClass().getName() methods.
- Example 33 is not working because "[name]" evaluates to null.
- Examples 34 and 35 show you that the out is not directly accessible, but it is an accessible
property of pageContext.
- Examples 36 and 37 show you that new elements can be added to implicit map object, sessionScope.
Exercise: Write an example JSP page to show how to create a JavaBean object,
and how to access the properties of this object with EL expressions.
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
Outdated Tutorials
References
PDF Printing Version