[Débutant] Filter dans l'application JEE (map)
Bonjour ,
Voila je veux que dans ma page list_tomodachi.jsp ci dessous , affiche tout les clients dans ma base de donnée même si la map est null , et en haut afficher que la personne qui viens de s'inscrire , pas tout les clients disponible , et tout ça en utilisant le filter , sauf que chez moi ca m'affiche dans le tableau les clients mais en haut devant ' Bienvenue a toi ' on m'affiche tout les nom et prenom de la base alors que je veux juste afficher la personne qui viens de s'inscrire , voila mon filter :
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24
| public void doFilter( ServletRequest req, ServletResponse res, FilterChain chain ) throws IOException,
ServletException {
HttpServletRequest request = (HttpServletRequest) req;
HttpSession session = request.getSession();
if ( session.getAttribute( sessionTomodachi ) == null ) {
ArrayList<Tomodachi> listeTomo = tomodachiDAO.listTomodachi();
Map<Long, Tomodachi> mapTomo = new HashMap<Long, Tomodachi>();
for ( Tomodachi tomodachi : listeTomo ) {
mapTomo.put( tomodachi.getId_tomodachi(), tomodachi );
}
session.setAttribute( sessionTomodachi, mapTomo );
}
chain.doFilter( request, res );
} |
La page list_tomodachi.jsp :
Code:
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 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55
| <body>
<div id="wrapper">
<!-- Header -->
<div id="header"> <span style="float:right;"> Bienvenue a toi<c:forEach items="${sessionScope.TomodachiSession}" var="mapTomo" > <c:out value="${mapTomo.value.nom}"/> <c:out value="${mapTomo.value.prenom}"/> </c:forEach> </div>
</div>
<!-- Header -->
</div>
<div style="clear:both"></div>
<!-- Content Area -->
<div id="middlepart">
<!-- Left column -->
<div id="leftcolumn">
<center>
<table border="1">
<thead>
<tr>
<th>Nom</th>
<th>Prénom</th>
<th>Age</th>
<th>Date d'inscription</th>
<th>Email</th>
<th>Ville</th>
</tr>
</thead>
<c:forEach items="${sessionScope.TomodachiSession}" var="mapTomo">
<tbody>
<tr>
<td><c:out value="${mapTomo.value.nom}"></c:out></td>
<td><c:out value="${mapTomo.value.prenom}"></c:out></td>
<td><c:out value="${mapTomo.value.age}"></c:out></td>
<td><c:out value="${mapTomo.value.date_inscription}"></c:out></td>
<td><c:out value="${mapTomo.value.email}"></c:out></td>
<td><c:out value="${mapTomo.value.ville}"></c:out></td>
</tr>
</tbody>
</c:forEach>
</table>
</center>
</body> |
merci