Page 108 - การโปรแกรมเว็บ
P. 108
7-96 การโปรแกรมเว็บ
<%@ taglib prefix = "c" uri = "http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix = "x" uri = "http://java.sun.com/jsp/jstl/xml" %>
ตัวอย่างท่ี 7.38 การใช้ <x: forEach>
MyJSP15_JSTL_foreach.jsp
1 <%@page contentType="text/html" pageEncoding="UTF-8"%>
2 <!DOCTYPE html>
3 <%@taglib prefix = "c" uri = "http://java.sun.com/jsp/jstl/core"%>
4 <%@taglib prefix = "x" uri = "http://java.sun.com/jsp/jstl/xml"%>
5 <html>
6 <head>
7 <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
8 <title>JSP Page</title>
9 </head>
10 <body>
11 <h3>Books list:</h3>
12 <c:set var = "xmlforEach">
13 <books>
14 <book>
15 <name>JSP Book</name>
16 <author>Dr.Nattapong Songneam</author>
17 <price>250</price>
18 </book>
19 <book>
20 <name>JAVA Book</name>
21 <author>Somchai</author>
22 <price>150</price>
23 </book>
24 </books>
25 </c:set>
26 <x:parse xml = "${xmlforEach}" var = "output"/>
27 <ul class = "list">