×

Welcome to TagMyCode

Please login or create account to add a snippet.
0
0
 
0
Language: Javascript
Posted by: Dread Morpheus
Added: Sep 30, 2017 12:48 AM
Views: 2556
  1. <%@page contentType="text/html" pageEncoding="UTF-8"%>
  2. <%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
  3. <!DOCTYPE html>
  4. <html>
  5.     <head>
  6.         <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
  7.         <title>Afficher une Collection</title>
  8.     </head>
  9.     <body style="font-size: x-large;align-content: center">
  10.         <table style="background-color: black; border-style: double; margin: auto; padding: auto;">
  11.             <thead style="color: blanchedalmond; text-align: center">
  12.                 <tr>
  13.                     <th>Nom</th>
  14.                     <th>Prénom</th>
  15.                     <th>Revenu</th>
  16.                     <th>Montant de Prêt</th>
  17.                     <th>Image</th>
  18.                 </tr>
  19.             </thead>
  20.             <tbody style="color: cornsilk; text-align: center">
  21.                 <c:forEach var="info" items="${sessionScope.maListe}" varStatus="index">
  22.                     <%--
  23.                     Check Even Odd Number in ForEach Loop : ForEach « JSTL « Java Tutorial
  24.                     java2s.com  | Email:info at java2s.com | © Demo Source and Support. All rights reserved.
  25.                     --%>
  26.                     <jsp:useBean id="index" type="javax.servlet.jsp.jstl.core.LoopTagStatus" />
  27.                     <c:choose>
  28.                         <c:when test="<%=index.getCount() % 2 == 0%>">
  29.                             <tr style="color: steelblue">
  30.                                 <td>${info.nom}</td>
  31.                                 <td>${info.prenom}</td>
  32.                                 <td>${info.revenu}</td>
  33.                                 <td>${info.montantPret}</td>
  34.                                 <%--
  35.                                 Image source must be a path, meaning you can`t import an image via a bean
  36.                                 or some such and then place it. You'll end up with file properties. Here I
  37.                                use a File object in the bean instead of the actual image. The file object
  38.                                holds the relative path of a bean's image, so it works both in java and jsp.
  39.                                 Thank you Stack Overflow!
  40.                                 --%>
  41.                                 <td><img src="<c:url value='${info.img}'/>" alt="" width="150" height="100" />
  42.                                 </td>
  43.                             </tr>
  44.                         </c:when>
  45.                         <c:otherwise>
  46.                             <tr>
  47.                                 <td>${info.nom}</td>
  48.                                 <td>${info.prenom}</td>
  49.                                 <td>${info.revenu}</td>
  50.                                 <td>${info.montantPret}</td>
  51.                                 <td><img src="<c:url value='${info.img}'/>" alt="" width="150" height="100" />
  52.                                 </td>
  53.                             </tr>
  54.                         </c:otherwise>
  55.                     </c:choose>
  56.                 </c:forEach>
  57.             </tbody>
  58.         </table>
  59.     </body>
  60. </html>
  61.