/* Copyright (c) SEMM NL All rights reserved.
Author : Paul Hamaker. Part of JavaLessons.com
This code is for educational purposes only. Use at own risk.*/

1. <%@ taglib 

2.  uri="http://java.sun.com/jsp/jstl/core" 

3.  prefix = "c" 

4. %>  

5. <%-- @ page isELIgnored="false" --%> 

6.  

7. <jsp:useBean id="bn" class="beens.Fone" scope="session" /> 

8.  

9. 1.  ${bn.name} :  ${bn.phone}  <hr

10.  

11. <jsp:setProperty 

12.   name="bn" property="phone" 

13.   value="${param.ph}"  /> 

14.    

15. 2.  ${bn.name} :  ${bn.phone}  <hr

16.  

17. <c:set value="${param.ph}" target="${bn}" property="phone" /> 

18.    

19. 3.  ${bn.name} :  ${bn.phone}  <hr

20.  

21. <c:set var="globalvar" scope="application"

22.   This is for all sessions 

23. </c:set> 

24. <c:remove var="globalvar" scope="application" /> 

25.  

26. <c:set var="tempnm" value="Albert" scope="page" /> 

27.  

28. <c:set value="${tempnm}" target="${bn}" property="name" /> 

29.  

30. 4.  ${bn.name} :  ${bn.phone}  <hr

31.  

32. <c:choose> 

33.   <c:when test='${ not empty param.nm }'

34.  

35.      <c:set value="${param.nm}" 

36.             target="${bn}" property="name" /> 

37.   </c:when> 

38.   <c:otherwise> 

39.  

40.     <c:set value="unknown" 

41.            target="${bn}" property="name" /> 

42.   </c:otherwise> 

43. </c:choose> 

44.  

45. 5.  ${bn.name} :  ${bn.phone}  <hr

46.  

47. 6. Param or default values :  

48. <c:out value="${param.nm}" 

49.   default="<i>no name parameter</i>" escapeXml="false" /> 

50. <c:out value="${param.ph}"

51.     <b>No phone parameter</b> 

52. </c:out> 

53.  

54. <br>7. If

55. <c:if test="${ bn.phone ge 10000 }"

56.   Phone number makes some sense. 

57. </c:if> 

58.  

59. <br>8. forEach : 

60. <% java.util.Properties colps = System.getProperties(); 

61.    pageContext.setAttribute("kollaxyun",colps); %> 

62.  

63. <ol> 

64. <c:forEach var="sprop" items="${kollaxyun}"

65.   <li>  ${sprop.key} = ${sprop.value} 

66.  </c:forEach> 

67. </ol> 

68.  

69. //======== Fone.java ================ 

70. package beens; 

71.   

72. public class Fone

73.   private String phone; 

74.   private String name; 

75.  

76.   public Fone() { 

77.     phone = "unknown"

78.     name = "unknown"

79.   } 

80.   public String getName() { 

81.     return name; 

82.   } 

83.   public void setName(String n) { 

84.     this.name = n; 

85.   } 

86.   public String getPhone() { 

87.     return phone; 

88.   } 

89.   public void setPhone(String p) { 

90.     this.phone = p; 

91.   } 

92.

93. =====EL============ 

94.  gt  ge  lt  le  eq  ne 

95.  not  and  or  empty 

96.