Problème d'affichage de page JSP suivant l'architecture MVC
Bonjour,
J'ai cree une page jsp pour afficher la liste des clients suivant une architecture MVC,voici l'erreur qui m'a donne:
Citation:
Une erreur s'est produite à la ligne: 10 dans le fichier jsp: /Client1.jsp
Client cannot be resolved to a type
7: <title>Liste des clients</title>
8: </head>
9: <body>
10: <jsp:useBean id="c1" class="Client" scope="session"></jsp:useBean>
11: <table border=1>
12: <tr>
13: <th>ID</th>
et voici le code de la page 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
|
<%@ 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>Liste des clients</title>
</head>
<body>
<jsp:useBean id="c1" class="Client" scope="session"></jsp:useBean>
<table border=1>
<tr>
<th>ID</th>
<th>NOM</th>
<th>EMAIL</th>
<th>Téléphone</th>
</tr>
<%
out.println("<tr><td>"+c1.getId()+"</td>");
out.println("<td>"+c1.getNom()+"</td>");
out.println("<td>"+c1.getEmail()+"</td>");
out.println("<td>"+c1.getTéléphone()+"</td></tr>");
%>
</table>
<a href="update.jsp">Modifier ici</a>
</body>
</html> |
et voici aussi le code du fichier du bean Client:Client.java
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 56 57 58 59 60 61
|
public class Client {
private int id;
private String nom;
private String email;
private int téléphone;
private String ville;
public int getId(){
return id;
}
public void setId(int id){
this.id=id;
}
public String getNom(){
return nom;
}
public void setNom(String nom){
this.nom=nom;
}
public String getEmail(){
return email;
}
public void setEmail(String email){
this.email=email;
}
public int getTéléphone(){
return téléphone;
}
public void setTéléphone(int téléphone){
this.téléphone=téléphone;
}
public String getVille(){
return ville;
}
public void setVille(String ville){
this.ville=ville;
}
} |
et aussi voici les codes des fichiers:Operateur.java et Utilitaire.java
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 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70
|
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.List;
public class Operateur {
public static Client user(int id,String nom)
{ //liste des clients
Client c=new Client();
Connection conn=Utilitaire.getConnection();
try {
PreparedStatement ps;
ps = conn.prepareStatement("select * from client where id=? AND nom= ?");
ps.setInt(1, id);
ps.setString(2, nom);
//résultat de la requete
ResultSet rs=ps.executeQuery();
while(rs.next())
{ //objet de type client pour stocker les champs
c.setId(rs.getInt("id"));
c.setNom(rs.getString("nom"));
c.setEmail(rs.getString("email"));
c.setTéléphone(rs.getInt("téléphone"));
}
}
catch (SQLException e)
{
e.printStackTrace();
}
return c;
}
public static void modifier(int id,String nom,String email,int téléphone)
{ //list des clients
Connection conn=Utilitaire.getConnection();
try {
PreparedStatement ps;
ps = conn.prepareStatement("UPDATE client SET nom=?,email=?,téléphone=? WHERE id=? ");
ps.setInt(1, id);
ps.setString(2, nom);
ps.setString(3, email);
ps.setInt(4, téléphone);
int n = ps.executeUpdate();
}
catch (SQLException e)
{
e.printStackTrace();
}
}
} |
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21
|
import java.sql.*;
public class Utilitaire {
private static Connection conn;
static{
try{
Class.forName("com.mysql.jdbc.Driver");
conn=DriverManager.getConnection("jdbc:mysql://localhost:8080/facture1","root","");
}
catch(Exception e){
e.printStackTrace();
}
}
public static Connection getConnection(){
return conn;
}
} |
sachant que ma base de donnee s'appelle clients et j'ai une seule table qui s'appelle client et le serveur est mysql pour la base de donnee
Et merci d'avance pour vos reponses