Bonjour,
J'ai un problème pour afficher les données provenant de ma bdd sur ma page jsp.
Sur la balise
Code : Sélectionner tout - Visualiser dans une fenêtre à part
<c:forEach var="p" items="${produits}">
il y a un warning d'eclipse, avec ce message
A problem was encountered using TagExtraInfo class org.apache.taglibs.standard.tei.ForEachTEI for 'c:forEach'
J'ai essayé plusieurs solutions trouvées sur le web mais aucune n'a marché.


Page jsp
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
 
<%@ page language="java" contentType="text/html; charset=UTF-8" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
 <table border="1">
		<tr>
			<th>DESIGNATION</th>
			<th>PRIX</th>
			<th>POIDS</th>
			<th>DATE PEREMPTION</th>
		</tr>	
		<c:forEach var="p" items="${produits}">
			<tr>
				<td><c:out value="${p.getDesignation}" /></td>
				<td><c:out value="${p.getPrix}" /></td>
				<td><c:out value="${p.getPoids}" /></td>
				<td><c:out value="${p.getDatePeremption}" /></td>
			</tr>	
		</c:forEach>
	</table>

Class Connexion BDD
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
public class ConnexionDB {
	private static Connection connection;
 
	static {
		try {
			Class.forName("com.mysql.jdbc.Driver");
 
			String url = "jdbc:mysql://localhost:3306/gestionproduit";
			String user = "root";
			String pass = "";
 
			connection = DriverManager.getConnection(url, user, pass);
		}
		catch(SQLException | ClassNotFoundException e) {
			e.printStackTrace();
		}
	}
 
	public static Connection getConnection() {
		return connection;
	}
 
}
Class Model
Code : Sélectionner tout - Visualiser dans une fenêtre à part
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
public class ProduitDAOImpl implements IProduit{
	Connection con = null;
	PreparedStatement ps = null;
	ResultSet rs = null;
 
	@SuppressWarnings("unused")
	public List<ProduitBean> getListeProduit() {
		List<ProduitBean> produit = new ArrayList<ProduitBean>();
 
		try{
 
			 con = ConnexionDB.getConnection();
			 ps = con.prepareStatement("SELECT * FROM produit");
			 rs = ps.executeQuery();
 
			while(rs.next()) {
 
				String designation = rs.getString("designation");
				Double prix = rs.getDouble("prix");
				Double poids = rs.getDouble("poids");
				Date datePeremption = rs.getDate("datePeremption");
 
				ProduitBean ListProduit = new ProduitBean();
				ListProduit.setDesignation(designation);
				ListProduit.setPrix(prix);
				ListProduit.setPoids(poids);
				ListProduit.setDatePeremption(datePeremption);
 
				produit.add(ListProduit);
			}
		}
		catch(SQLException e) {
			e.printStackTrace();
		} finally {
			try {
				if(rs != null) {
					rs.close();
				}
 
				if(ps != null) {
					ps.close();
				}
 
				if(con != null) {
					con.close();
				}
			} catch(SQLException ignore){
 
			}
		}
 
		return produit;
	}}
Class java Bean
Code : Sélectionner tout - Visualiser dans une fenêtre à part
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
56
57
58
59
60
61
62
63
64
65
66
67
public class ProduitBean {
	private int id;
	private String designation ;
	private Double prix;
	private Double poids;
	private Date datePeremption;
 
	public ProduitBean() {
		super();
	}
 
	public ProduitBean(String designation, Double prix, Double poids, Date dateperemption) {
		this.designation = designation;
		this.prix = prix;
		this.poids = poids;
		this.datePeremption = dateperemption;
	}
 
	public ProduitBean(int id, String designation, Double prix, Double poids, Date dateperemption) {
		this.id = id;
		this.designation = designation;
		this.prix = prix;
		this.poids = poids;
		this.datePeremption = dateperemption;
	}
 
	public int getId() {
		return id;
	}
 
	public void setId(int id) {
		this.id = id;
	}
 
	public String getDesignation() {
		return designation;
	}
 
	public void setDesignation(String designation) {
		this.designation = designation;
	}
 
	public Double getPrix() {
		return prix;
	}
 
	public void setPrix(Double prix) {
		this.prix = prix;
	}
 
	public Double getPoids() {
		return poids;
	}
 
	public void setPoids(Double poids) {
		this.poids = (double) poids;
	}
 
	public Date getDatePeremption() {
		return datePeremption;
	}
 
	public void setDatePeremption(Date datePeremption2) {
		this.datePeremption = datePeremption2;
	}
 
}

NB : lorsque j'instancie la connexion et lance la requête directement dans dans ma page avec un while next, les données s'affichent sans problème
Nom : Capture d’écran 2023-09-25 à 16.19.10.png
Affichages : 303
Taille : 27,2 Ko