Page 101 - การโปรแกรมเว็บ
P. 101
เจเอสพี 7-89
บรรทดั ท่ี 11 ค�ำส่งั ปิดแทก็ if
บรรทดั ที่ 12 ค�ำสั่งแท็กปิดสว่ นเน้อื หาของเว็บ
บรรทัดท่ี 13 ค�ำส่ังแทก็ ปิด html
ผลการทำ� งานของโปรแกรมแสดงดงั ภาพท่ี 7.33
ภาพท่ี 7.33 แสดงผลการใช้แท็ก <c: if>
ตัวอย่างที่ 7.35 การใช้ <c: when>
MyJSP15_JSTL_when.jsp
1 <%@page contentType="text/html" pageEncoding="UTF-8"%>
2 <!DOCTYPE html>
3 <%@taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
4 <html>
5 <head>
6 <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
7 <title>JSP Page</title>
8 </head>
9 <body>
10 <c:set var = "score" scope = "session" value = "${85}"/>
11 <p>Your score is : <c:out value = "${score}"/></p>
12 <c:choose>
13 <c:when test = "${score > 70}">
14 You Score is Height
15 </c:when>
16 <c:when test = "${score >= 50}">
17 You Score is Medium