JSP and EL: EL Expression Examples : EL « JSP « Java

Java
1. 2D Graphics GUI
2. 3D
3. Advanced Graphics
4. Ant
5. Apache Common
6. Chart
7. Collections Data Structure
8. Database SQL JDBC
9. Design Pattern
10. Development Class
11. Email
12. Event
13. File Input Output
14. Game
15. Hibernate
16. J2EE
17. J2ME
18. JDK 6
19. JSP
20. JSTL
21. Language Basics
22. Network Protocol
23. PDF RTF
24. Regular Expressions
25. Security
26. Servlets
27. Spring
28. Swing Components
29. Swing JFC
30. SWT JFace Eclipse
31. Threads
32. Tiny Application
33. Velocity
34. Web Services SOA
35. XML
Microsoft Office Word 2007 Tutorial
Java Tutorial
Java Source Code / Java Documentation
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
C# / C Sharp
C# / CSharp Tutorial
ASP.Net
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
PHP
Python
SQL Server / T-SQL
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Java » JSP » ELScreenshots 
JSP and EL: EL Expression Examples


/*
Beginning JavaServer Pages
Vivek Chopra, Jon Eaves, Rupert Jones, Sing Li, John T. Bell
ISBN: 0-7645-7485-X

*/


<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<%@ taglib prefix="wroxtags" tagdir="/WEB-INF/tags" %>


<html>
<head>
<title>EL Expression Examples</title>
</head>
<body>
<h1>EL Expression Examples</h1>

<h2>Arithmetic Operators in Expressions</h2>
<c:set var="appleCount" value="${1 + 2 * 4 - 6 / 2}"/>
<b>There are ${2apples on the table.</b><br/>
<b>There are 
<fmt:formatNumber pattern="#####"> ${2}</fmt:formatNumber>
apples on the table.</b><br/>


<b>It feels like ${-8degree today.</b><br/>
<c:set var="myGrade" value="11"/><br/>
<b>The average grade is ${(myGrade == 10"perfect" "good"}. </b><br/>
<b>There are ${23/54remaining. </b><br/>
<b>There are ${div 2apples on the table.</b><br/>
<b>There are ${2003 div 8apples on the table.</b><br/>
<b>There are ${2003 mod 8apples on the table.</b><br/>
<b>There are ${2003 8apples on the table.</b><br/>

<h2>Logical Operators</h2>
<c:set var="guess" value="12"/>
<b>Your guess is ${guess}.</b><br/>

<c:if test="${(guess >= 10)  && (guess <= 20)}">
   <b>You're in range!</b><br/>
</c:if>
<c:if test="${(guess < 10)  || (guess > 20)}">
   <b>Try again!</b><br/>
</c:if>

<c:set var="guess" value="1"/>
<b>Your guess is ${guess}.</b><br/>

<c:if test="${(guess >= 10)  and (guess <= 20)}">
   <b>You're in range!</b><br/>
</c:if>
<c:if test="${(guess < 10)  or (guess > 20)}">
   <b>Try again!</b><br/>
</c:if>



<h2>Comparison Operators</h2>

'3'   ${'3'}<br/>
'4' 3   ${'4' 3}<br/>
'4' '3' ${'4' '3'<br/>
>= 3    ${>= 3}<br/>
<= 3     ${3}<br/>
== '4'   ${== 4}<br/>

<h2>empty Operator</h2>
empty "" ${empty ""}<br/>
empty "sometext" ${empty "sometext"}<br/>
empty Junk ${empty Junk}<br/>
empty guess ${empty guess}<br/> 


<h2>Boolean and Null Values</h2>

<c:set var="StrVar" value="true"/>
<c:if test="${StrVar}">
  equal!
</c:if><br/>

null == null  ${null == null}<br/>
"null" == null ${"null" == null}<br/>


</body>
</html>


           
       
BeginningJavaServerPages-ch05-1.zip( 291 k)
Related examples in the same category
1. EL and Complex JavaBeans
2. EL and Complex JavaBeans 1
3. EL Arithmetic
4. JSP and EL: EL Type Conversion Examples
5. JSP and EL:EL Property Access and Nested Properties
6. JSP and EL: Implicit Object Example Form processorJSP and EL: Implicit Object Example Form processor
7. EL Function Examples
w_w___w.__j__a___v___a_2s__._c___o__m | Contact Us
Copyright 2003 - 08 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.