Subscribe

RSS Feed (xml)

Powered By

Skin Design:
Free Blogger Skins

Powered by Blogger

Saturday, December 1, 2007

java code for 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" %>




EL Expression Examples


EL Expression Examples



Arithmetic Operators in Expressions



There are ${1 + 2 * 4 - 6 / 2} apples on the table.

There are
${1 + 2 * 4 - 6 / 2}
apples on the table.




It feels like ${-4 - 8} degree today.



The average grade is ${(myGrade == 10) ? "perfect" : "good"}.

There are ${23/54} remaining.

There are ${6 div 2} apples on the table.

There are ${2003 div 8} apples on the table.

There are ${2003 mod 8} apples on the table.

There are ${2003 % 8} apples on the table.


Logical Operators



Your guess is ${guess}.



You're in range!



Try again!




Your guess is ${guess}.



You're in range!



Try again!





Comparison Operators



4 > '3' ${4 > '3'}

'4' > 3 ${'4' > 3}

'4' > '3' ${'4' > '3'}

4 >= 3 ${4 >= 3}

4 <= 3 ${4 < 3}

4 == '4' ${4 == 4}


empty Operator


empty "" ${empty ""}

empty "sometext" ${empty "sometext"}

empty Junk ${empty Junk}

empty guess ${empty guess}



Boolean and Null Values





equal!



null == null ${null == null}

"null" == null ${"null" == null}




No comments: