Java Reference
In-Depth Information
and is shown in Listing 3-58. This JSP retrieves the list of active products from the servlet
context and displays them.
Listing 3-58. ProductLoV.jsp
<%@ taglib prefix="c" uri=" http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="fmt" uri=" http://java.sun.com/jsp/jstl/fmt" %>
<html>
<head>
<title>LoV - Product</title>
</head>
<body>
<table>
<tr>
<td>Product Id</td>
<td>Product Name</td>
</tr>
<c:forEach var="productDtl" items="${applicationScope.productDtlList}" >
<tr>
<td><c:out value="${productDtl.productId}"/></td>
<td><c:out value="${productDtl.productName}"/></td>
</tr>
</c:forEach>
</table>
</body>
</html>
As shown in Listing 3-58, we are using a JSTL-based view helper to retrieve and
present the data stored in application scope. applicationScope is an implicit object avail-
able with the JSTL Expression Language, and it gives a handle to the servlet context. In
Listing 3-58, it looks for an attribute with the key productDtlList in the servlet context.
To use this semistatic view, you need to slightly alter the configuration, as shown in
Listing 3-59. Note that the SimpleUrlHandlerMapping has been configured to handle
UrlFilenameViewController .
 
Search WWH ::




Custom Search