resulution bug
This commit is contained in:
11
pom.xml
11
pom.xml
@@ -19,6 +19,17 @@
|
|||||||
<version>${jakartaee}</version>
|
<version>${jakartaee}</version>
|
||||||
<scope>provided</scope>
|
<scope>provided</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>jakarta.platform</groupId>
|
||||||
|
<artifactId>jakarta.jakartaee-web-api</artifactId>
|
||||||
|
<version>10.0.0</version>
|
||||||
|
<scope>provided</scope>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.mariadb.jdbc</groupId>
|
||||||
|
<artifactId>mariadb-java-client</artifactId>
|
||||||
|
<version>3.3.2</version>
|
||||||
|
</dependency>
|
||||||
</dependencies>
|
</dependencies>
|
||||||
|
|
||||||
<build>
|
<build>
|
||||||
|
|||||||
37
src/main/java/com/test/bdd/ClientJpa.java
Normal file
37
src/main/java/com/test/bdd/ClientJpa.java
Normal file
@@ -0,0 +1,37 @@
|
|||||||
|
/*
|
||||||
|
* Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license
|
||||||
|
* Click nbfs://nbhost/SystemFileSystem/Templates/Classes/Class.java to edit this template
|
||||||
|
*/
|
||||||
|
package com.test.bdd;
|
||||||
|
|
||||||
|
import com.test.beans.Client;
|
||||||
|
import jakarta.ejb.Stateless;
|
||||||
|
import jakarta.persistence.EntityManager;
|
||||||
|
import jakarta.persistence.PersistenceContext;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @author emile.malcuit
|
||||||
|
*/
|
||||||
|
@Stateless //type EJB, logique métier, à injecter dans les autres classes avec @EJB
|
||||||
|
public class ClientJpa {
|
||||||
|
|
||||||
|
@PersistenceContext(unitName = "bdclientPU") //en lien avec le fichier persistence.xml : <persistence-unit name="bdclientPU" transaction-type="JTA">
|
||||||
|
private EntityManager em;
|
||||||
|
|
||||||
|
// Lecture de tous les clients
|
||||||
|
public List<Client> readAll() {
|
||||||
|
List<Client> lesClients = em.createQuery("SELECT c FROM Client c", Client.class).getResultList();
|
||||||
|
return lesClients;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Création d’un client
|
||||||
|
public int create(Client unClient) {
|
||||||
|
em.persist(unClient); // enregistre l’objet en base
|
||||||
|
// Force la synchro avec la base pour récupérer l’ID tout de suite
|
||||||
|
em.flush();
|
||||||
|
return unClient.getId(); // l’ID est rempli automatiquement par JPA
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -9,7 +9,7 @@ import java.sql.ResultSet;
|
|||||||
import java.sql.SQLException;
|
import java.sql.SQLException;
|
||||||
import java.sql.Statement;
|
import java.sql.Statement;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import com.test.beans.Client;
|
import com.test.beans.ClientOld;
|
||||||
import java.sql.PreparedStatement;
|
import java.sql.PreparedStatement;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -17,8 +17,7 @@ import java.sql.PreparedStatement;
|
|||||||
* @author emile.malcuit
|
* @author emile.malcuit
|
||||||
*/
|
*/
|
||||||
public class ClientMysql {
|
public class ClientMysql {
|
||||||
private Connection laConnexion = connexionSQL.getConnect("192.168.100.100", "bdclient", "adminClient", "admin");
|
private Connection laConnexion = connexionSQL.getConnect("192.168.100.100", "bdclient", "adminClient", "mdpBDclient");
|
||||||
|
|
||||||
public ClientMysql() {
|
public ClientMysql() {
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -27,7 +26,7 @@ public class ClientMysql {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public void createClient(Client newCli) {
|
public void createClient(ClientOld newCli) {
|
||||||
String commande = "INSERT INTO client(nom, prenom, mail) VALUES (?, ?, ?)";
|
String commande = "INSERT INTO client(nom, prenom, mail) VALUES (?, ?, ?)";
|
||||||
|
|
||||||
try (PreparedStatement pstmt = laConnexion.prepareStatement(commande)) {
|
try (PreparedStatement pstmt = laConnexion.prepareStatement(commande)) {
|
||||||
@@ -47,14 +46,14 @@ public class ClientMysql {
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
public ArrayList<Client> readAll(){
|
public ArrayList<ClientOld> readAll(){
|
||||||
ArrayList<Client> lesClients=new ArrayList<>();
|
ArrayList<ClientOld> lesClients=new ArrayList<>();
|
||||||
try {
|
try {
|
||||||
Statement stmt=laConnexion.createStatement();
|
Statement stmt=laConnexion.createStatement();
|
||||||
ResultSet resultQ=null;
|
ResultSet resultQ=null;
|
||||||
resultQ=stmt.executeQuery("SELECT * FROM client;");
|
resultQ=stmt.executeQuery("SELECT * FROM client;");
|
||||||
while (resultQ.next()){
|
while (resultQ.next()){
|
||||||
Client resultat=new Client(resultQ.getInt("id"),resultQ.getString("nom"),resultQ.getString("prenom"),resultQ.getString("mail"));
|
ClientOld resultat=new ClientOld(resultQ.getInt("id"),resultQ.getString("nom"),resultQ.getString("prenom"),resultQ.getString("mail"));
|
||||||
lesClients.add(resultat);
|
lesClients.add(resultat);
|
||||||
}
|
}
|
||||||
resultQ.close();
|
resultQ.close();
|
||||||
@@ -70,9 +69,9 @@ public class ClientMysql {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public Client read(int id){
|
public ClientOld read(int id){
|
||||||
String commande = "SELECT * FROM client WHERE id = ?";
|
String commande = "SELECT * FROM client WHERE id = ?";
|
||||||
Client recherche = new Client();
|
ClientOld recherche = new ClientOld();
|
||||||
|
|
||||||
try(PreparedStatement pstmt = laConnexion.prepareStatement(commande)){
|
try(PreparedStatement pstmt = laConnexion.prepareStatement(commande)){
|
||||||
pstmt.setString(1, Integer.toString(id));
|
pstmt.setString(1, Integer.toString(id));
|
||||||
|
|||||||
32
src/main/java/com/test/bdd/SalarieJpa.java
Normal file
32
src/main/java/com/test/bdd/SalarieJpa.java
Normal file
@@ -0,0 +1,32 @@
|
|||||||
|
/*
|
||||||
|
* Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license
|
||||||
|
* Click nbfs://nbhost/SystemFileSystem/Templates/Classes/Class.java to edit this template
|
||||||
|
*/
|
||||||
|
package com.test.bdd;
|
||||||
|
|
||||||
|
import com.test.beans.Salarie;
|
||||||
|
import jakarta.ejb.Stateless;
|
||||||
|
import jakarta.persistence.EntityManager;
|
||||||
|
import jakarta.persistence.PersistenceContext;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @author emile.malcuit
|
||||||
|
*/
|
||||||
|
@Stateless
|
||||||
|
public class SalarieJpa {
|
||||||
|
@PersistenceContext(unitName = "bdclientPU") //en lien avec le fichier persistence.xml : <persistence-unit name="bdclientPU" transaction-type="JTA">
|
||||||
|
private EntityManager em;
|
||||||
|
|
||||||
|
// Lecture de tous les clients
|
||||||
|
public List<Salarie> readAll() {
|
||||||
|
List<Salarie> lesSalaries = em.createQuery("SELECT c FROM Salarie c", Salarie.class).getResultList();
|
||||||
|
return lesSalaries;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Salarie find(Salarie unSalarie){
|
||||||
|
return em.find(Salarie.class, unSalarie);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -4,7 +4,7 @@
|
|||||||
*/
|
*/
|
||||||
package com.test.bdd;
|
package com.test.bdd;
|
||||||
|
|
||||||
import com.test.beans.Salarie;
|
import com.test.beans.SalarieOld;
|
||||||
import java.sql.Connection;
|
import java.sql.Connection;
|
||||||
import java.sql.PreparedStatement;
|
import java.sql.PreparedStatement;
|
||||||
import java.sql.ResultSet;
|
import java.sql.ResultSet;
|
||||||
@@ -15,14 +15,14 @@ import java.sql.SQLException;
|
|||||||
* @author emile.malcuit
|
* @author emile.malcuit
|
||||||
*/
|
*/
|
||||||
public class SalarieMySQL {
|
public class SalarieMySQL {
|
||||||
private Connection laConnexion = connexionSQL.getConnect("192.168.100.100", "bdclient", "adminClient", "admin");
|
private Connection laConnexion = connexionSQL.getConnect("192.168.100.100", "bdclient", "adminClient", "mdpBDclient");
|
||||||
|
|
||||||
public SalarieMySQL() {
|
public SalarieMySQL() {
|
||||||
}
|
}
|
||||||
|
|
||||||
public Salarie read(String nom, String mdp){
|
public SalarieOld read(String nom, String mdp){
|
||||||
String commande = "SELECT * FROM salarie WHERE nom = ? and mdp = ?";
|
String commande = "SELECT * FROM salarie WHERE nom = ? and mdp = ?";
|
||||||
Salarie recherche = new Salarie();
|
SalarieOld recherche = new SalarieOld();
|
||||||
|
|
||||||
try(PreparedStatement pstmt = laConnexion.prepareStatement(commande)){
|
try(PreparedStatement pstmt = laConnexion.prepareStatement(commande)){
|
||||||
pstmt.setString(1, nom);
|
pstmt.setString(1, nom);
|
||||||
|
|||||||
@@ -4,19 +4,32 @@
|
|||||||
*/
|
*/
|
||||||
package com.test.beans;
|
package com.test.beans;
|
||||||
|
|
||||||
|
import jakarta.persistence.Entity;
|
||||||
|
import jakarta.persistence.GeneratedValue;
|
||||||
|
import jakarta.persistence.GenerationType;
|
||||||
|
import jakarta.persistence.Id;
|
||||||
|
import jakarta.persistence.Table;
|
||||||
|
import java.io.Serializable;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @author emile.malcuit
|
* @author emile.malcuit
|
||||||
*/
|
*/
|
||||||
|
@Entity // indique que c’est une entité gérée par JPA
|
||||||
|
@Table(name = "client") // nom de la table SQL dans la bd liée
|
||||||
|
|
||||||
public class Client {
|
public class Client {
|
||||||
|
|
||||||
|
//Annotations pour gérer id auto-incrémenté
|
||||||
|
@Id
|
||||||
|
@GeneratedValue(strategy = GenerationType.IDENTITY) // clé primaire auto-incrémentée
|
||||||
private int id;
|
private int id;
|
||||||
|
|
||||||
private String nom;
|
private String nom;
|
||||||
private String prenom;
|
private String prenom;
|
||||||
private String mail;
|
private String mail;
|
||||||
|
|
||||||
|
public Client() {} // obligatoire pour JPA (constructeur vide)
|
||||||
public Client() {
|
|
||||||
}
|
|
||||||
|
|
||||||
public Client(int id, String nom, String prenom, String mail) {
|
public Client(int id, String nom, String prenom, String mail) {
|
||||||
this.id=id;
|
this.id=id;
|
||||||
@@ -25,48 +38,39 @@ public class Client {
|
|||||||
this.mail = mail;
|
this.mail = mail;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Client(String nom, String prenom, String mail) {
|
||||||
|
|
||||||
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;
|
this.nom = nom;
|
||||||
}
|
|
||||||
|
|
||||||
public String getPrenom() {
|
|
||||||
return prenom;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setPrenom(String prenom) {
|
|
||||||
this.prenom = prenom;
|
this.prenom = prenom;
|
||||||
}
|
|
||||||
|
|
||||||
public String getMail() {
|
|
||||||
return mail;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setMail(String mail) {
|
|
||||||
this.mail = mail;
|
this.mail = mail;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Getters, setters, toString() identiques
|
||||||
|
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 getPrenom()
|
||||||
|
{ return prenom; }
|
||||||
|
|
||||||
|
public void setPrenom(String prenom)
|
||||||
|
{ this.prenom = prenom; }
|
||||||
|
|
||||||
|
public String getMail()
|
||||||
|
{ return mail; }
|
||||||
|
|
||||||
|
public void setMail(String mail)
|
||||||
|
{ this.mail = mail; }
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return "Client{" + "id=" + id + ", nom=" + nom + ", prenom=" + prenom + ", mail=" + mail + '}';
|
return "Client{" + "id=" + id + ", nom=" + nom + ", prenom=" + prenom + ", mail=" + mail + '}';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
72
src/main/java/com/test/beans/ClientOld.java
Normal file
72
src/main/java/com/test/beans/ClientOld.java
Normal file
@@ -0,0 +1,72 @@
|
|||||||
|
/*
|
||||||
|
* Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license
|
||||||
|
* Click nbfs://nbhost/SystemFileSystem/Templates/Classes/Class.java to edit this template
|
||||||
|
*/
|
||||||
|
package com.test.beans;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @author emile.malcuit
|
||||||
|
*/
|
||||||
|
public class ClientOld {
|
||||||
|
private int id;
|
||||||
|
private String nom;
|
||||||
|
private String prenom;
|
||||||
|
private String mail;
|
||||||
|
|
||||||
|
|
||||||
|
public ClientOld() {
|
||||||
|
}
|
||||||
|
|
||||||
|
public ClientOld(int id, String nom, String prenom, String mail) {
|
||||||
|
this.id = id;
|
||||||
|
this.nom = nom;
|
||||||
|
this.prenom = prenom;
|
||||||
|
this.mail = mail;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
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 getPrenom() {
|
||||||
|
return prenom;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setPrenom(String prenom) {
|
||||||
|
this.prenom = prenom;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getMail() {
|
||||||
|
return mail;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setMail(String mail) {
|
||||||
|
this.mail = mail;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
return "Client{" + "id=" + id + ", nom=" + nom + ", prenom=" + prenom + ", mail=" + mail + '}';
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
@@ -4,21 +4,42 @@
|
|||||||
*/
|
*/
|
||||||
package com.test.beans;
|
package com.test.beans;
|
||||||
|
|
||||||
import java.util.Objects;
|
import jakarta.persistence.Entity;
|
||||||
|
import jakarta.persistence.GeneratedValue;
|
||||||
|
import jakarta.persistence.GenerationType;
|
||||||
|
import jakarta.persistence.Id;
|
||||||
|
import jakarta.persistence.Table;
|
||||||
|
import java.io.Serializable;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @author emile.malcuit
|
* @author emile.malcuit
|
||||||
*/
|
*/
|
||||||
public class Salarie {
|
@Entity // indique que c’est une entité gérée par JPA
|
||||||
|
@Table(name = "salarie") // nom de la table SQL dans la bd liée
|
||||||
|
public class Salarie implements Serializable {
|
||||||
|
|
||||||
|
@Id
|
||||||
|
@GeneratedValue(strategy = GenerationType.IDENTITY) // clé primaire auto-incrémentée
|
||||||
private int id;
|
private int id;
|
||||||
|
|
||||||
private String nom;
|
private String nom;
|
||||||
private String mdp;
|
private String mdp;
|
||||||
private boolean isAdmin;
|
private boolean isAdmin;
|
||||||
|
|
||||||
|
public Salarie(){}
|
||||||
|
|
||||||
|
public Salarie(int id, String nom, String mdp, boolean isAdmin) {
|
||||||
|
this.id=id;
|
||||||
|
this.nom = nom;
|
||||||
|
this.mdp = mdp;
|
||||||
|
this.isAdmin = isAdmin;
|
||||||
|
}
|
||||||
|
|
||||||
public Salarie() {
|
public Salarie(String nom, String mdp, boolean isAdmin) {
|
||||||
|
this.nom = nom;
|
||||||
|
this.mdp = mdp;
|
||||||
|
this.isAdmin = isAdmin;
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getId() {
|
public int getId() {
|
||||||
@@ -53,7 +74,12 @@ public class Salarie {
|
|||||||
this.isAdmin = isAdmin;
|
this.isAdmin = isAdmin;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int hashCode() {
|
||||||
|
int hash = 7;
|
||||||
|
hash = 67 * hash + this.id;
|
||||||
|
return hash;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean equals(Object obj) {
|
public boolean equals(Object obj) {
|
||||||
@@ -67,13 +93,14 @@ public class Salarie {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
final Salarie other = (Salarie) obj;
|
final Salarie other = (Salarie) obj;
|
||||||
if (!Objects.equals(this.nom, other.nom)) {
|
return this.id == other.id;
|
||||||
return false;
|
|
||||||
}
|
|
||||||
return Objects.equals(this.mdp, other.mdp);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
return "com.test.beans.Salarie[ id=" + id + " ]";
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
79
src/main/java/com/test/beans/SalarieOld.java
Normal file
79
src/main/java/com/test/beans/SalarieOld.java
Normal file
@@ -0,0 +1,79 @@
|
|||||||
|
/*
|
||||||
|
* Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license
|
||||||
|
* Click nbfs://nbhost/SystemFileSystem/Templates/Classes/Class.java to edit this template
|
||||||
|
*/
|
||||||
|
package com.test.beans;
|
||||||
|
|
||||||
|
import java.util.Objects;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @author emile.malcuit
|
||||||
|
*/
|
||||||
|
public class SalarieOld {
|
||||||
|
private int id;
|
||||||
|
private String nom;
|
||||||
|
private String mdp;
|
||||||
|
private boolean isAdmin;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
public SalarieOld() {
|
||||||
|
}
|
||||||
|
|
||||||
|
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 getMdp() {
|
||||||
|
return mdp;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setMdp(String mdp) {
|
||||||
|
this.mdp = mdp;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isIsAdmin() {
|
||||||
|
return isAdmin;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setIsAdmin(boolean isAdmin) {
|
||||||
|
this.isAdmin = isAdmin;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean equals(Object obj) {
|
||||||
|
if (this == obj) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
if (obj == null) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if (getClass() != obj.getClass()) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
final SalarieOld other = (SalarieOld) obj;
|
||||||
|
if (!Objects.equals(this.nom, other.nom)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return Objects.equals(this.mdp, other.mdp);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
@@ -4,7 +4,8 @@
|
|||||||
*/
|
*/
|
||||||
package com.test.forms;
|
package com.test.forms;
|
||||||
|
|
||||||
import com.test.beans.Salarie;
|
import com.test.beans.SalarieOld;
|
||||||
|
import jakarta.ejb.EJB;
|
||||||
import jakarta.servlet.http.HttpServletRequest;
|
import jakarta.servlet.http.HttpServletRequest;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -12,6 +13,9 @@ import jakarta.servlet.http.HttpServletRequest;
|
|||||||
* @author emile.malcuit
|
* @author emile.malcuit
|
||||||
*/
|
*/
|
||||||
public class AuthentifForm {
|
public class AuthentifForm {
|
||||||
|
@EJB
|
||||||
|
|
||||||
|
|
||||||
private String resultat = "Vous n'êtes pas administrateur";
|
private String resultat = "Vous n'êtes pas administrateur";
|
||||||
|
|
||||||
public String getResultat() {
|
public String getResultat() {
|
||||||
@@ -23,11 +27,11 @@ public class AuthentifForm {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public boolean controlerAdmin(Salarie unSalarie){ //HttpServletRequest request
|
public boolean controlerAdmin(SalarieOld unSalarie){ //HttpServletRequest request
|
||||||
//Salarie admin = new Salarie("Lovelace", "Ada");
|
//Salarie admin = new SalarieOld("Lovelace", "Ada");
|
||||||
//String login = request.getParameter("user_name");
|
//String login = request.getParameter("user_name");
|
||||||
//String mdp = request.getParameter("user_password");
|
//String mdp = request.getParameter("user_password");
|
||||||
//Salarie userSaisi = new Salarie(login, mdp);
|
//Salarie userSaisi = new SalarieOld(login, mdp);
|
||||||
boolean retour = false;
|
boolean retour = false;
|
||||||
if(unSalarie.isIsAdmin()){
|
if(unSalarie.isIsAdmin()){
|
||||||
retour = true;
|
retour = true;
|
||||||
|
|||||||
37
src/main/java/com/test/forms/ListeForm.java
Normal file
37
src/main/java/com/test/forms/ListeForm.java
Normal file
@@ -0,0 +1,37 @@
|
|||||||
|
/*
|
||||||
|
* Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license
|
||||||
|
* Click nbfs://nbhost/SystemFileSystem/Templates/Classes/Class.java to edit this template
|
||||||
|
*/
|
||||||
|
package com.test.forms;
|
||||||
|
|
||||||
|
import com.test.bdd.ClientJpa;
|
||||||
|
import com.test.beans.Client;
|
||||||
|
import jakarta.ejb.EJB;
|
||||||
|
import jakarta.ejb.Stateless;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @author emile.malcuit
|
||||||
|
*/
|
||||||
|
@Stateless //type EJB
|
||||||
|
public class ListeForm {
|
||||||
|
@EJB //pour utiliser la classe ClientJPA définie en @Stateless
|
||||||
|
private ClientJpa dao;
|
||||||
|
|
||||||
|
private String resultat;
|
||||||
|
|
||||||
|
public String getResultat() {
|
||||||
|
return resultat;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setResultat(String resultat) {
|
||||||
|
this.resultat = resultat;
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<Client> readClient(){
|
||||||
|
List<Client> lesClients = dao.readAll();
|
||||||
|
System.out.println("Les clients récuprés");
|
||||||
|
return lesClients;
|
||||||
|
}
|
||||||
|
}
|
||||||
45
src/main/java/com/test/forms/NouveauClientForm.java
Normal file
45
src/main/java/com/test/forms/NouveauClientForm.java
Normal file
@@ -0,0 +1,45 @@
|
|||||||
|
/*
|
||||||
|
* Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license
|
||||||
|
* Click nbfs://nbhost/SystemFileSystem/Templates/Classes/Class.java to edit this template
|
||||||
|
*/
|
||||||
|
package com.test.forms;
|
||||||
|
|
||||||
|
import com.test.bdd.ClientJpa;
|
||||||
|
import com.test.beans.Client;
|
||||||
|
import jakarta.ejb.EJB;
|
||||||
|
import jakarta.ejb.Stateless;
|
||||||
|
import jakarta.servlet.http.HttpServletRequest;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @author emile.malcuit
|
||||||
|
*/
|
||||||
|
@Stateless //type EJB
|
||||||
|
public class NouveauClientForm {
|
||||||
|
@EJB //pour utiliser la classe ClientJPA définie en @Stateless
|
||||||
|
private ClientJpa dao;
|
||||||
|
|
||||||
|
private String resultat;
|
||||||
|
|
||||||
|
public String getResultat() {
|
||||||
|
return resultat;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setResultat(String resultat) {
|
||||||
|
this.resultat = resultat;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int verifierClient(HttpServletRequest request){
|
||||||
|
int id=-1;
|
||||||
|
|
||||||
|
String leNom = request.getParameter("nom");
|
||||||
|
String lePrenom =request.getParameter("prenom");
|
||||||
|
|
||||||
|
if ((lePrenom.matches("[A-Za-zÀ-ÖØ-öø-ÿ' -]{1,100}"))&& (leNom.matches("[A-Za-zÀ-ÖØ-öø-ÿ' -]{1,100}"))){
|
||||||
|
Client cliSaisi = new Client(request.getParameter("nom"),request.getParameter("prenom"),request.getParameter("email") );
|
||||||
|
id = dao.create(cliSaisi);
|
||||||
|
System.out.println("Client créé avec id : " + id);
|
||||||
|
}
|
||||||
|
return id;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -82,6 +82,7 @@ public class AcceuilServlet extends HttpServlet {
|
|||||||
String mdp = request.getParameter("user_password");
|
String mdp = request.getParameter("user_password");
|
||||||
String test;
|
String test;
|
||||||
if (login != null && !login.isBlank()) {
|
if (login != null && !login.isBlank()) {
|
||||||
|
System.out.println("Hello world 1");
|
||||||
test = verifConnexion(login , mdp);
|
test = verifConnexion(login , mdp);
|
||||||
request.setAttribute("login", login);
|
request.setAttribute("login", login);
|
||||||
request.setAttribute("connect",test);
|
request.setAttribute("connect",test);
|
||||||
|
|||||||
@@ -5,7 +5,7 @@
|
|||||||
package com.test.servlets;
|
package com.test.servlets;
|
||||||
|
|
||||||
import com.test.bdd.SalarieMySQL;
|
import com.test.bdd.SalarieMySQL;
|
||||||
import com.test.beans.Salarie;
|
import com.test.beans.SalarieOld;
|
||||||
import com.test.forms.AuthentifForm;
|
import com.test.forms.AuthentifForm;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.PrintWriter;
|
import java.io.PrintWriter;
|
||||||
@@ -14,6 +14,7 @@ import jakarta.servlet.annotation.WebServlet;
|
|||||||
import jakarta.servlet.http.HttpServlet;
|
import jakarta.servlet.http.HttpServlet;
|
||||||
import jakarta.servlet.http.HttpServletRequest;
|
import jakarta.servlet.http.HttpServletRequest;
|
||||||
import jakarta.servlet.http.HttpServletResponse;
|
import jakarta.servlet.http.HttpServletResponse;
|
||||||
|
import jakarta.servlet.http.HttpSession;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
@@ -79,12 +80,18 @@ public class AuthentifServlet extends HttpServlet {
|
|||||||
//Recupération de l'éssaie de connexion
|
//Recupération de l'éssaie de connexion
|
||||||
String nom = request.getParameter("user_name");
|
String nom = request.getParameter("user_name");
|
||||||
String mdp = request.getParameter("user_password");
|
String mdp = request.getParameter("user_password");
|
||||||
Salarie unSalarie = new SalarieMySQL().read(nom, mdp);
|
SalarieOld unSalarie = new SalarieMySQL().read(nom, mdp);
|
||||||
|
|
||||||
//Vérification des droits
|
//Vérification des droits
|
||||||
AuthentifForm authent = new AuthentifForm();
|
AuthentifForm authent = new AuthentifForm();
|
||||||
boolean isAdmin = authent.controlerAdmin(unSalarie);
|
boolean isAdmin = authent.controlerAdmin(unSalarie);
|
||||||
String status = authent.getResultat();
|
String status = authent.getResultat();
|
||||||
|
HttpSession session = request.getSession(true);
|
||||||
|
if(isAdmin){
|
||||||
|
session.setAttribute("isAuthorised", "yes");
|
||||||
|
}else{
|
||||||
|
session.setAttribute("isAuthorised", "no");
|
||||||
|
}
|
||||||
request.setAttribute("isAdmin", isAdmin);
|
request.setAttribute("isAdmin", isAdmin);
|
||||||
request.setAttribute("status", status);
|
request.setAttribute("status", status);
|
||||||
request.setAttribute("pseudo", unSalarie.getNom());
|
request.setAttribute("pseudo", unSalarie.getNom());
|
||||||
|
|||||||
@@ -4,8 +4,12 @@
|
|||||||
*/
|
*/
|
||||||
package com.test.servlets;
|
package com.test.servlets;
|
||||||
|
|
||||||
|
import com.test.bdd.ClientJpa;
|
||||||
import com.test.bdd.ClientMysql;
|
import com.test.bdd.ClientMysql;
|
||||||
import com.test.beans.Client;
|
import com.test.beans.Client;
|
||||||
|
import com.test.beans.ClientOld;
|
||||||
|
import com.test.forms.ListeForm;
|
||||||
|
import jakarta.ejb.EJB;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.PrintWriter;
|
import java.io.PrintWriter;
|
||||||
import jakarta.servlet.ServletException;
|
import jakarta.servlet.ServletException;
|
||||||
@@ -13,7 +17,9 @@ import jakarta.servlet.annotation.WebServlet;
|
|||||||
import jakarta.servlet.http.HttpServlet;
|
import jakarta.servlet.http.HttpServlet;
|
||||||
import jakarta.servlet.http.HttpServletRequest;
|
import jakarta.servlet.http.HttpServletRequest;
|
||||||
import jakarta.servlet.http.HttpServletResponse;
|
import jakarta.servlet.http.HttpServletResponse;
|
||||||
|
import jakarta.servlet.http.HttpSession;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
@@ -21,7 +27,8 @@ import java.util.ArrayList;
|
|||||||
*/
|
*/
|
||||||
@WebServlet(name="ListeServlet", urlPatterns={"/ListeClients"})
|
@WebServlet(name="ListeServlet", urlPatterns={"/ListeClients"})
|
||||||
public class ListeServlet extends HttpServlet {
|
public class ListeServlet extends HttpServlet {
|
||||||
|
@EJB
|
||||||
|
private ListeForm leControle; // injecté par Jakarta EE grâce à @EJB, géré par le contrôleur
|
||||||
/**
|
/**
|
||||||
* Processes requests for both HTTP <code>GET</code> and <code>POST</code>
|
* Processes requests for both HTTP <code>GET</code> and <code>POST</code>
|
||||||
* methods.
|
* methods.
|
||||||
@@ -61,11 +68,18 @@ public class ListeServlet extends HttpServlet {
|
|||||||
protected void doGet(HttpServletRequest request, HttpServletResponse response)
|
protected void doGet(HttpServletRequest request, HttpServletResponse response)
|
||||||
throws ServletException, IOException {
|
throws ServletException, IOException {
|
||||||
//processRequest(request, response);
|
//processRequest(request, response);
|
||||||
ClientMysql UnClient = new ClientMysql();
|
HttpSession session = request.getSession(true);
|
||||||
ArrayList<Client> lesClients = UnClient.readAll();
|
if(session.getAttribute("isAuthorised").equals("yes")){
|
||||||
|
//ClientMysql UnClient = new ClientMysql();
|
||||||
|
//ArrayList<ClientOld> lesClients = UnClient.readAll();
|
||||||
|
|
||||||
|
List<Client> lesClients= leControle.readClient();
|
||||||
request.setAttribute("lesClients", lesClients);
|
request.setAttribute("lesClients", lesClients);
|
||||||
getServletContext().getRequestDispatcher("/WEB-INF/ListeClientsJSP.jsp").forward(request, response);
|
getServletContext().getRequestDispatcher("/WEB-INF/ListeClientsJSP.jsp").forward(request, response);
|
||||||
|
}else{
|
||||||
|
getServletContext().getRequestDispatcher("/WEB-INF/AcceuilJSP.jsp").forward(request, response);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
95
src/main/java/com/test/servlets/ModifServlet.java
Normal file
95
src/main/java/com/test/servlets/ModifServlet.java
Normal file
@@ -0,0 +1,95 @@
|
|||||||
|
/*
|
||||||
|
* Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license
|
||||||
|
* Click nbfs://nbhost/SystemFileSystem/Templates/JSP_Servlet/Servlet.java to edit this template
|
||||||
|
*/
|
||||||
|
package com.test.servlets;
|
||||||
|
|
||||||
|
import com.test.bdd.ClientMysql;
|
||||||
|
import com.test.beans.ClientOld;
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.io.PrintWriter;
|
||||||
|
import jakarta.servlet.ServletException;
|
||||||
|
import jakarta.servlet.annotation.WebServlet;
|
||||||
|
import jakarta.servlet.http.HttpServlet;
|
||||||
|
import jakarta.servlet.http.HttpServletRequest;
|
||||||
|
import jakarta.servlet.http.HttpServletResponse;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @author emile.malcuit
|
||||||
|
*/
|
||||||
|
@WebServlet(name="ModifServlet", urlPatterns={"/Modification"})
|
||||||
|
public class ModifServlet extends HttpServlet {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Processes requests for both HTTP <code>GET</code> and <code>POST</code>
|
||||||
|
* methods.
|
||||||
|
*
|
||||||
|
* @param request servlet request
|
||||||
|
* @param response servlet response
|
||||||
|
* @throws ServletException if a servlet-specific error occurs
|
||||||
|
* @throws IOException if an I/O error occurs
|
||||||
|
*/
|
||||||
|
protected void processRequest(HttpServletRequest request, HttpServletResponse response)
|
||||||
|
throws ServletException, IOException {
|
||||||
|
response.setContentType("text/html;charset=UTF-8");
|
||||||
|
try (PrintWriter out = response.getWriter()) {
|
||||||
|
/* TODO output your page here. You may use following sample code. */
|
||||||
|
out.println("<!DOCTYPE html>");
|
||||||
|
out.println("<html>");
|
||||||
|
out.println("<head>");
|
||||||
|
out.println("<title>Servlet ModifServlet</title>");
|
||||||
|
out.println("</head>");
|
||||||
|
out.println("<body>");
|
||||||
|
out.println("<h1>Servlet ModifServlet at " + request.getContextPath() + "</h1>");
|
||||||
|
out.println("</body>");
|
||||||
|
out.println("</html>");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// <editor-fold defaultstate="collapsed" desc="HttpServlet methods. Click on the + sign on the left to edit the code.">
|
||||||
|
/**
|
||||||
|
* Handles the HTTP <code>GET</code> method.
|
||||||
|
*
|
||||||
|
* @param request servlet request
|
||||||
|
* @param response servlet response
|
||||||
|
* @throws ServletException if a servlet-specific error occurs
|
||||||
|
* @throws IOException if an I/O error occurs
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
protected void doGet(HttpServletRequest request, HttpServletResponse response)
|
||||||
|
throws ServletException, IOException {
|
||||||
|
int id = (int) request.getAttribute("id");
|
||||||
|
ClientMysql cliSQL = new ClientMysql();
|
||||||
|
ClientOld leClient = cliSQL.read(id);
|
||||||
|
|
||||||
|
request.setAttribute("leClient", leClient);
|
||||||
|
//getServletContext().getRequestDispatcher("/WEB-INF/modifierClientJSP.jsp").forward(request, response);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Handles the HTTP <code>POST</code> method.
|
||||||
|
*
|
||||||
|
* @param request servlet request
|
||||||
|
* @param response servlet response
|
||||||
|
* @throws ServletException if a servlet-specific error occurs
|
||||||
|
* @throws IOException if an I/O error occurs
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
protected void doPost(HttpServletRequest request, HttpServletResponse response)
|
||||||
|
throws ServletException, IOException {
|
||||||
|
processRequest(request, response);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns a short description of the servlet.
|
||||||
|
*
|
||||||
|
* @return a String containing servlet description
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public String getServletInfo() {
|
||||||
|
return "Short description";
|
||||||
|
}// </editor-fold>
|
||||||
|
|
||||||
|
}
|
||||||
@@ -5,7 +5,9 @@
|
|||||||
package com.test.servlets;
|
package com.test.servlets;
|
||||||
|
|
||||||
import com.test.bdd.ClientMysql;
|
import com.test.bdd.ClientMysql;
|
||||||
import com.test.beans.Client;
|
import com.test.beans.ClientOld;
|
||||||
|
import com.test.forms.NouveauClientForm;
|
||||||
|
import jakarta.ejb.EJB;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.PrintWriter;
|
import java.io.PrintWriter;
|
||||||
import jakarta.servlet.ServletException;
|
import jakarta.servlet.ServletException;
|
||||||
@@ -13,6 +15,7 @@ import jakarta.servlet.annotation.WebServlet;
|
|||||||
import jakarta.servlet.http.HttpServlet;
|
import jakarta.servlet.http.HttpServlet;
|
||||||
import jakarta.servlet.http.HttpServletRequest;
|
import jakarta.servlet.http.HttpServletRequest;
|
||||||
import jakarta.servlet.http.HttpServletResponse;
|
import jakarta.servlet.http.HttpServletResponse;
|
||||||
|
import jakarta.servlet.http.HttpSession;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
@@ -20,6 +23,8 @@ import jakarta.servlet.http.HttpServletResponse;
|
|||||||
*/
|
*/
|
||||||
@WebServlet(name="NouveauServlet", urlPatterns={"/NouveauClient"})
|
@WebServlet(name="NouveauServlet", urlPatterns={"/NouveauClient"})
|
||||||
public class NouveauServlet extends HttpServlet {
|
public class NouveauServlet extends HttpServlet {
|
||||||
|
@EJB
|
||||||
|
private NouveauClientForm leControle; // injecté par Jakarta EE grâce à @EJB, géré par le contrôleur
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Processes requests for both HTTP <code>GET</code> and <code>POST</code>
|
* Processes requests for both HTTP <code>GET</code> and <code>POST</code>
|
||||||
@@ -60,7 +65,12 @@ public class NouveauServlet extends HttpServlet {
|
|||||||
protected void doGet(HttpServletRequest request, HttpServletResponse response)
|
protected void doGet(HttpServletRequest request, HttpServletResponse response)
|
||||||
throws ServletException, IOException {
|
throws ServletException, IOException {
|
||||||
//processRequest(request, response);
|
//processRequest(request, response);
|
||||||
|
HttpSession session = request.getSession(true);
|
||||||
|
if(session.getAttribute("isAuthorised").equals("yes")){
|
||||||
getServletContext().getRequestDispatcher("/WEB-INF/NouveauClientJSP.jsp").forward(request, response);
|
getServletContext().getRequestDispatcher("/WEB-INF/NouveauClientJSP.jsp").forward(request, response);
|
||||||
|
}else{
|
||||||
|
getServletContext().getRequestDispatcher("/WEB-INF/AcceuilJSP.jsp").forward(request, response);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -77,7 +87,8 @@ public class NouveauServlet extends HttpServlet {
|
|||||||
throws ServletException, IOException {
|
throws ServletException, IOException {
|
||||||
|
|
||||||
//Recuperation des informations inserer dans le formulaire nouveau client
|
//Recuperation des informations inserer dans le formulaire nouveau client
|
||||||
Client newCli = new Client();
|
/**
|
||||||
|
ClientOld newCli = new ClientOld();
|
||||||
newCli.setNom(request.getParameter("nom"));
|
newCli.setNom(request.getParameter("nom"));
|
||||||
newCli.setPrenom(request.getParameter("prenom"));
|
newCli.setPrenom(request.getParameter("prenom"));
|
||||||
newCli.setMail(request.getParameter("email"));
|
newCli.setMail(request.getParameter("email"));
|
||||||
@@ -85,6 +96,9 @@ public class NouveauServlet extends HttpServlet {
|
|||||||
//Insertion du client en db
|
//Insertion du client en db
|
||||||
ClientMysql cliSQL = new ClientMysql();
|
ClientMysql cliSQL = new ClientMysql();
|
||||||
cliSQL.createClient(newCli);
|
cliSQL.createClient(newCli);
|
||||||
|
*/
|
||||||
|
leControle.verifierClient(request);
|
||||||
|
System.out.println("test EJB");
|
||||||
|
|
||||||
response.sendRedirect(request.getContextPath() + "/ListeClients");
|
response.sendRedirect(request.getContextPath() + "/ListeClients");
|
||||||
|
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ package com.test.servlets;
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
import com.test.bdd.ClientMysql;
|
import com.test.bdd.ClientMysql;
|
||||||
import com.test.beans.Client;
|
import com.test.beans.ClientOld;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.PrintWriter;
|
import java.io.PrintWriter;
|
||||||
import jakarta.servlet.ServletException;
|
import jakarta.servlet.ServletException;
|
||||||
@@ -42,8 +42,8 @@ public class TestClientSQL extends HttpServlet {
|
|||||||
out.println("</head>");
|
out.println("</head>");
|
||||||
out.println("<body>");
|
out.println("<body>");
|
||||||
ClientMysql UnClient = new ClientMysql();
|
ClientMysql UnClient = new ClientMysql();
|
||||||
ArrayList<Client> lesClients = UnClient.readAll();
|
ArrayList<ClientOld> lesClients = UnClient.readAll();
|
||||||
for(Client unClient:lesClients){
|
for(ClientOld unClient:lesClients){
|
||||||
out.println(unClient.toString());
|
out.println(unClient.toString());
|
||||||
}
|
}
|
||||||
out.println("<h1>Servlet TestClientSQL at " + request.getContextPath() + "</h1>");
|
out.println("<h1>Servlet TestClientSQL at " + request.getContextPath() + "</h1>");
|
||||||
|
|||||||
@@ -1,7 +1,15 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<persistence version="3.0" xmlns="https://jakarta.ee/xml/ns/persistence" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="https://jakarta.ee/xml/ns/persistence https://jakarta.ee/xml/ns/persistence/persistence_3_0.xsd">
|
<persistence version="3.0" xmlns="https://jakarta.ee/xml/ns/persistence" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="https://jakarta.ee/xml/ns/persistence https://jakarta.ee/xml/ns/persistence/persistence_3_0.xsd">
|
||||||
<!-- Define Persistence Unit -->
|
<!-- Define Persistence Unit -->
|
||||||
<persistence-unit name="my_persistence_unit">
|
<persistence-unit name="bdclientPU" transaction-type="JTA">
|
||||||
|
<jta-data-source>jdbc/bdclient</jta-data-source>
|
||||||
|
<properties>
|
||||||
|
<property name="jakarta.persistence.jdbc.driver" value="org.mariadb.jdbc.Driver"/>
|
||||||
|
<property name="jakarta.persistence.jdbc.url" value="jdbc:mariadb://192.168.100.100/bdclient"/>
|
||||||
|
<property name="jakarta.persistence.jdbc.user" value="adminClient"/>
|
||||||
|
<property name="jakarta.persistence.jdbc.password" value="mdpBDclient"/>
|
||||||
|
<!-- Optionnel : génération du schéma -->
|
||||||
|
<property name="jakarta.persistence.schema-generation.database.action" value="none"/>
|
||||||
|
</properties>
|
||||||
</persistence-unit>
|
</persistence-unit>
|
||||||
</persistence>
|
</persistence>
|
||||||
|
|||||||
@@ -29,6 +29,7 @@
|
|||||||
<th>Nom</th>
|
<th>Nom</th>
|
||||||
<th>Prénom</th>
|
<th>Prénom</th>
|
||||||
<th>Mail</th>
|
<th>Mail</th>
|
||||||
|
<th>Mofication</th>
|
||||||
</tr>
|
</tr>
|
||||||
<c:forEach var="client" items="${lesClients}">
|
<c:forEach var="client" items="${lesClients}">
|
||||||
<tr>
|
<tr>
|
||||||
@@ -36,6 +37,7 @@
|
|||||||
<td>${client.nom}</td>
|
<td>${client.nom}</td>
|
||||||
<td>${client.prenom}</td>
|
<td>${client.prenom}</td>
|
||||||
<td>${client.mail}</td>
|
<td>${client.mail}</td>
|
||||||
|
<td><a href="/Modification?id=${client.id}">Modification</td>
|
||||||
</tr>
|
</tr>
|
||||||
</c:forEach>
|
</c:forEach>
|
||||||
</table>
|
</table>
|
||||||
|
|||||||
41
src/main/webapp/WEB-INF/modifierClientJSP.jsp
Normal file
41
src/main/webapp/WEB-INF/modifierClientJSP.jsp
Normal file
@@ -0,0 +1,41 @@
|
|||||||
|
<%--
|
||||||
|
Document : modifierClientJSP.jsp
|
||||||
|
Created on : 3 oct. 2025, 13:46:53
|
||||||
|
Author : emile.malcuit
|
||||||
|
--%>
|
||||||
|
|
||||||
|
<%@page contentType="text/html" pageEncoding="UTF-8"%>
|
||||||
|
<!DOCTYPE html>
|
||||||
|
<html>
|
||||||
|
<head>
|
||||||
|
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
|
||||||
|
<title>Modification d'un client</title>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
|
||||||
|
<%@include file="jspf/entete.jspf" %>
|
||||||
|
<%@include file="jspf/menu.jspf" %>
|
||||||
|
<h1>Bonjour Les Zouaves</h1>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<p>Modification d’un client </p>
|
||||||
|
</br>
|
||||||
|
|
||||||
|
<form action="${pageContext.request.contextPath}/Modification" method="POST">
|
||||||
|
|
||||||
|
<label for="nom">Nom :</label><br />
|
||||||
|
<input type="text" id="nom" name="nom" value="${leClient.nom}" required /><br /><br />
|
||||||
|
|
||||||
|
<label for="prenom">Prénom :</label><br />
|
||||||
|
<input type="text" id="prenom" name="prenom" value="${leClient.prenom}" required /><br /><br />
|
||||||
|
|
||||||
|
<label for="email">E-mail :</label><br />
|
||||||
|
<input type="text" id="email" name="email" value="${leClient.mail}" required /><br /><br />
|
||||||
|
|
||||||
|
<div class="valider">
|
||||||
|
<input type="submit" value="Insérer" />
|
||||||
|
</div>
|
||||||
|
</form>
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
@@ -1,5 +1,8 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<web-app version="6.0" xmlns="https://jakarta.ee/xml/ns/jakartaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="https://jakarta.ee/xml/ns/jakartaee https://jakarta.ee/xml/ns/jakartaee/web-app_6_0.xsd">
|
<web-app version="6.0" xmlns="https://jakarta.ee/xml/ns/jakartaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="https://jakarta.ee/xml/ns/jakartaee https://jakarta.ee/xml/ns/jakartaee/web-app_6_0.xsd">
|
||||||
|
<welcome-file-list>
|
||||||
|
<welcome-file>Acceuil</welcome-file>
|
||||||
|
</welcome-file-list>
|
||||||
<servlet>
|
<servlet>
|
||||||
<servlet-name>AcceuilServlet</servlet-name>
|
<servlet-name>AcceuilServlet</servlet-name>
|
||||||
<servlet-class>com.test.servlets.AcceuilServlet</servlet-class>
|
<servlet-class>com.test.servlets.AcceuilServlet</servlet-class>
|
||||||
@@ -20,6 +23,10 @@
|
|||||||
<servlet-name>TestClientSQL</servlet-name>
|
<servlet-name>TestClientSQL</servlet-name>
|
||||||
<servlet-class>com.test.servlets.TestClientSQL</servlet-class>
|
<servlet-class>com.test.servlets.TestClientSQL</servlet-class>
|
||||||
</servlet>
|
</servlet>
|
||||||
|
<servlet>
|
||||||
|
<servlet-name>ModifServlet</servlet-name>
|
||||||
|
<servlet-class>com.test.servlets.ModifServlet</servlet-class>
|
||||||
|
</servlet>
|
||||||
<servlet-mapping>
|
<servlet-mapping>
|
||||||
<servlet-name>AcceuilServlet</servlet-name>
|
<servlet-name>AcceuilServlet</servlet-name>
|
||||||
<url-pattern>/Acceuil</url-pattern>
|
<url-pattern>/Acceuil</url-pattern>
|
||||||
@@ -40,6 +47,10 @@
|
|||||||
<servlet-name>TestClientSQL</servlet-name>
|
<servlet-name>TestClientSQL</servlet-name>
|
||||||
<url-pattern>/TestClientSQL</url-pattern>
|
<url-pattern>/TestClientSQL</url-pattern>
|
||||||
</servlet-mapping>
|
</servlet-mapping>
|
||||||
|
<servlet-mapping>
|
||||||
|
<servlet-name>ModifServlet</servlet-name>
|
||||||
|
<url-pattern>/Modification</url-pattern>
|
||||||
|
</servlet-mapping>
|
||||||
<session-config>
|
<session-config>
|
||||||
<session-timeout>
|
<session-timeout>
|
||||||
30
|
30
|
||||||
|
|||||||
Reference in New Issue
Block a user