In this JavaEE JSP JSTL Tutorial, we will use JSTL to access the Java Bean object. Here, we create second version of displaybook.jsp file which eliminates the script-let syntax and uses JSTL Tags.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 |
<!-- Sample 01: Add Taglib Library --> <%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %> <%@ page language="java" contentType="text/html; charset=ISO-8859-1" pageEncoding="ISO-8859-1"%> <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"> <title>Books List from Pubs DB</title> </head> <body> <!-- Sample 02: Title for the Display --> <h2 style="background-color:gray; "> Book Title using JSTL Library & JSP Expression </h2> <!-- Sample 03: Use JSP EL and TagLibrary For Loop --> <c:forEach var="Book" items="${BookTitles}"> <p style=background-color:silver > Book Title: ${Book.bookTitle} </p> <p> Type: ${Book.type} </p> <p> Price:${Book.bookPrice} </p> </c:forEach> <!-- Sample 04: Note: The Title.java file is changed to use this new JSP File --> </body> </html> |
Categories: JSP