From 1ec492d570799bb73550dd807b86b62cc4eefc3d Mon Sep 17 00:00:00 2001 From: "clementine.desrucques" Date: Thu, 21 Oct 2021 15:58:27 +0200 Subject: [PATCH 1/4] --- src/java/bdd/PompierMySql.java | 2 +- src/java/com/test/forms/NouveauPompForm.java | 42 +++++++++---------- .../com/test/servlets/authentifServlet.java | 2 +- web/WEB-INF/CreaPompier.jsp | 4 +- 4 files changed, 26 insertions(+), 24 deletions(-) diff --git a/src/java/bdd/PompierMySql.java b/src/java/bdd/PompierMySql.java index 6ec6945..fded535 100644 --- a/src/java/bdd/PompierMySql.java +++ b/src/java/bdd/PompierMySql.java @@ -172,7 +172,7 @@ public class PompierMySql { String login = request.getParameter("ztPseudo"); String mdp = request.getParameter("ztMDP"); String mdpChiffre = MD5.encode(request.getParameter("ztMDP")); - String sql = "SELECT * FROM pompier WHERE login='" + login + "' AND mdp='" + mdpChiffre + "';"; + String sql = "SELECT * FROM pompier WHERE login='" + login + "' AND mdp='" + mdpChiffre + "' AND typePers='1';"; System.out.println("sql:" + sql); try { Statement stmt = theConnection.createStatement(); diff --git a/src/java/com/test/forms/NouveauPompForm.java b/src/java/com/test/forms/NouveauPompForm.java index b21a715..d5bb3dc 100644 --- a/src/java/com/test/forms/NouveauPompForm.java +++ b/src/java/com/test/forms/NouveauPompForm.java @@ -22,13 +22,13 @@ public class NouveauPompForm { public int verifNouveauPompier(HttpServletRequest request) { // Contrôle du no de rue qui doit être numérique - String noRueString = request.getParameter("nAdrNo"); - boolean isNumeric = StringUtils.isStrictlyNumeric(noRueString); - if (!isNumeric) { - message = "Le no de rue doit être numérique"; - return -1; - } - int noRue = Integer.parseInt(noRueString); +// String noRueString = request.getParameter("nAdrNo"); +// boolean isNumeric = StringUtils.isStrictlyNumeric(noRueString); +// if (!isNumeric) { +// message = "Le no de rue doit être numérique"; +// return -1; +// } +// int noRue = Integer.parseInt(noRueString); // Contrôle car "<" dans les zones de texte //String [] lesSaisies = request.getParameterValues(noRueString); // Valeurs saisies @@ -45,22 +45,22 @@ public class NouveauPompForm { } if (erreur > 0) return -1; -// Creation d'un objet de type Client avec les données transmises +// Creation d'un objet de type Pompier avec les données transmises Pompier unPompier = new Pompier( - request.getParameter("id"), - request.getParameter("idCaserne"), - request.getParameter("nom"), - request.getParameter("prenom"), - request.getParameter("statut"), - request.getParameter("mail"), - request.getParameter("login"), - request.getParameter("mdp"), - noRue, - request.getParameter("adrRue"), - request.getParameter("adrCP"), - request.getParameter("adrVille"), - request.getParameter("grade"), + + Integer.parseInt(request.getParameter("nIdCaserne")), + request.getParameter("ztNom"), + request.getParameter("ztPrenom"), + Integer.parseInt(request.getParameter("nStatut")), + request.getParameter("eMail"), + request.getParameter("ztPseudo"), + request.getParameter("ztMDP"), + Integer.parseInt(request.getParameter("nAdrNo")), + request.getParameter("ztAdrRue"), + request.getParameter("ztAdrCP"), + request.getParameter("ztAdrVille"), + Integer.parseInt(request.getParameter("nGrade")), request.getParameter("commentaire") ); PompierMySql cm = new PompierMySql(); diff --git a/src/java/com/test/servlets/authentifServlet.java b/src/java/com/test/servlets/authentifServlet.java index 5418849..68a01ef 100644 --- a/src/java/com/test/servlets/authentifServlet.java +++ b/src/java/com/test/servlets/authentifServlet.java @@ -87,7 +87,7 @@ public class authentifServlet extends HttpServlet { // Affichage de la JSP if(isAuthentified==true){ - getServletContext().getRequestDispatcher("/WEB-INF/PompierJSP.jsp") + getServletContext().getRequestDispatcher("/WEB-INF/ChefCaserneJSP.jsp") .forward(request, response); }else{ getServletContext().getRequestDispatcher("/WEB-INF/accueilJSP.jsp") diff --git a/web/WEB-INF/CreaPompier.jsp b/web/WEB-INF/CreaPompier.jsp index 22cf622..5ff4a9c 100644 --- a/web/WEB-INF/CreaPompier.jsp +++ b/web/WEB-INF/CreaPompier.jsp @@ -27,7 +27,7 @@

-

+



@@ -40,6 +40,8 @@



+ +

From a9dec9bae42879121fc280f705cc2c4aa39ecd24 Mon Sep 17 00:00:00 2001 From: "clementine.desrucques" Date: Thu, 21 Oct 2021 16:23:58 +0200 Subject: [PATCH 2/4] --- src/java/bdd/PompierMySql.java | 17 +++++++++++++++++ web/WEB-INF/accueilJSP.jsp | 33 ++++++++++++++++++--------------- 2 files changed, 35 insertions(+), 15 deletions(-) diff --git a/src/java/bdd/PompierMySql.java b/src/java/bdd/PompierMySql.java index fded535..392eae1 100644 --- a/src/java/bdd/PompierMySql.java +++ b/src/java/bdd/PompierMySql.java @@ -196,6 +196,19 @@ public class PompierMySql { resultQ.getInt("grade"), resultQ.getString("commentaire") ); + + switch(resultQ.getInt("statut")){ + case 1: + setResultat("Pompier"); + break; + case 2: + setResultat("Chef"); + break; + case 3: + setResultat("Alerte"); + break; + } + HttpSession maSession = request.getSession(); maSession.setAttribute("lePompier", lePompier); } @@ -206,4 +219,8 @@ public class PompierMySql { return resultat; } + private void setResultat(String pompier) { + throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. + } + } diff --git a/web/WEB-INF/accueilJSP.jsp b/web/WEB-INF/accueilJSP.jsp index 79994f7..967095e 100644 --- a/web/WEB-INF/accueilJSP.jsp +++ b/web/WEB-INF/accueilJSP.jsp @@ -9,19 +9,22 @@ <%@page contentType="text/html" pageEncoding="UTF-8"%> -
- Authentification -
-
-

- -
-
- - - -

${controlForm.getResultat()}

- +
+ Authentification +
+
+

+ +
+
-
\ No newline at end of file + +

${controlForm.getResultat()}

+
+ + + + + + From cd2d0e634f998cfa83bb35ad7564c8d98a24ce5a Mon Sep 17 00:00:00 2001 From: "clementine.desrucques" Date: Thu, 21 Oct 2021 16:35:09 +0200 Subject: [PATCH 3/4] --- src/java/bdd/PompierMySql.java | 16 +-- src/java/com/test/beans/Pompier.java | 158 ++++++++++++++++++--------- web/WEB-INF/accueilJSP.jsp | 7 +- 3 files changed, 111 insertions(+), 70 deletions(-) diff --git a/src/java/bdd/PompierMySql.java b/src/java/bdd/PompierMySql.java index 392eae1..8efb559 100644 --- a/src/java/bdd/PompierMySql.java +++ b/src/java/bdd/PompierMySql.java @@ -186,28 +186,18 @@ public class PompierMySql { resultQ.getString("nom"), resultQ.getString("prenom"), resultQ.getInt("statut"), + resultQ.getInt("typePers"), resultQ.getString("mail"), resultQ.getString("login"), resultQ.getString("mdp"), resultQ.getInt("adrNo"), resultQ.getString("adrRue"), - resultQ.getString("adrCP"), - resultQ.getString("adrVille"), + resultQ.getString("cp"), + resultQ.getString("ville"), resultQ.getInt("grade"), resultQ.getString("commentaire") ); - switch(resultQ.getInt("statut")){ - case 1: - setResultat("Pompier"); - break; - case 2: - setResultat("Chef"); - break; - case 3: - setResultat("Alerte"); - break; - } HttpSession maSession = request.getSession(); maSession.setAttribute("lePompier", lePompier); diff --git a/src/java/com/test/beans/Pompier.java b/src/java/com/test/beans/Pompier.java index bcbedb6..bb8e356 100644 --- a/src/java/com/test/beans/Pompier.java +++ b/src/java/com/test/beans/Pompier.java @@ -17,35 +17,56 @@ public class Pompier { private String nom; private String prenom; private int statut; + private int typePers; private String mail; private String login; private String mdp; - private int adrNo; - private String adrRue; - private String adrCP; - private String adrVille; + private String adresse; + private String cp; + private String ville; + private int bip; + private int nbGrade; private int grade; private String commentaire; + private int idEmployeur; - public Pompier(int id, int idCaserne, String nom, String prenom, int statut, String mail, String login, String mdp, int adrNo, String adrRue, String adrCP, String adrVille, int grade, String commentaire) { - this(idCaserne, nom, prenom, statut, mail, login, mdp, adrNo, adrRue, adrCP, adrVille, grade, commentaire); + public Pompier(int id, int idCaserne, String nom, String prenom, int statut, int typePers, String mail, String login, String mdp, String adresse, String cp, String ville, int bip, int nbGrade, int grade, String commentaire, int idEmployeur) { this.id = id; - } - - public Pompier(int idCaserne, String nom, String prenom, int statut, String mail, String login, String mdp, int adrNo, String adrRue, String adrCP, String adrVille, int grade, String commentaire) { this.idCaserne = idCaserne; this.nom = nom; this.prenom = prenom; this.statut = statut; + this.typePers = typePers; this.mail = mail; this.login = login; this.mdp = mdp; - this.adrNo = adrNo; - this.adrRue = adrRue; - this.adrCP = adrCP; - this.adrVille = adrVille; + this.adresse = adresse; + this.cp = cp; + this.ville = ville; + this.bip = bip; + this.nbGrade = nbGrade; this.grade = grade; this.commentaire = commentaire; + this.idEmployeur = idEmployeur; + } + + public Pompier(int idCaserne, String nom, String prenom, int statut, int typePers, String mail, String login, String mdp, String adresse, String cp, String ville, int bip, int nbGrade, int grade, String commentaire, int idEmployeur) { + this.idCaserne = idCaserne; + this.nom = nom; + this.prenom = prenom; + this.statut = statut; + this.typePers = typePers; + this.mail = mail; + this.login = login; + this.mdp = mdp; + this.adresse = adresse; + this.cp = cp; + this.ville = ville; + this.bip = bip; + this.nbGrade = nbGrade; + this.grade = grade; + this.commentaire = commentaire; + this.idEmployeur = idEmployeur; } public int getId() { @@ -88,6 +109,14 @@ public class Pompier { this.statut = statut; } + public int getTypePers() { + return typePers; + } + + public void setTypePers(int typePers) { + this.typePers = typePers; + } + public String getMail() { return mail; } @@ -112,36 +141,44 @@ public class Pompier { this.mdp = mdp; } - public int getAdrNo() { - return adrNo; + public String getAdresse() { + return adresse; } - public void setAdrNo(int adrNo) { - this.adrNo = adrNo; + public void setAdresse(String adresse) { + this.adresse = adresse; } - public String getAdrRue() { - return adrRue; + public String getCp() { + return cp; } - public void setAdrRue(String adrRue) { - this.adrRue = adrRue; + public void setCp(String cp) { + this.cp = cp; } - public String getAdrCP() { - return adrCP; + public String getVille() { + return ville; } - public void setAdrCP(String adrCP) { - this.adrCP = adrCP; + public void setVille(String ville) { + this.ville = ville; } - public String getAdrVille() { - return adrVille; + public int getBip() { + return bip; } - public void setAdrVille(String adrVille) { - this.adrVille = adrVille; + public void setBip(int bip) { + this.bip = bip; + } + + public int getNbGrade() { + return nbGrade; + } + + public void setNbGrade(int nbGrade) { + this.nbGrade = nbGrade; } public int getGrade() { @@ -160,23 +197,34 @@ public class Pompier { this.commentaire = commentaire; } + public int getIdEmployeur() { + return idEmployeur; + } + + public void setIdEmployeur(int idEmployeur) { + this.idEmployeur = idEmployeur; + } + @Override public int hashCode() { int hash = 3; - hash = 29 * hash + this.id; - hash = 29 * hash + this.idCaserne; - hash = 29 * hash + Objects.hashCode(this.nom); - hash = 29 * hash + Objects.hashCode(this.prenom); - hash = 29 * hash + this.statut; - hash = 29 * hash + Objects.hashCode(this.mail); - hash = 29 * hash + Objects.hashCode(this.login); - hash = 29 * hash + Objects.hashCode(this.mdp); - hash = 29 * hash + this.adrNo; - hash = 29 * hash + Objects.hashCode(this.adrRue); - hash = 29 * hash + Objects.hashCode(this.adrCP); - hash = 29 * hash + Objects.hashCode(this.adrVille); - hash = 29 * hash + this.grade; - hash = 29 * hash + Objects.hashCode(this.commentaire); + hash = 67 * hash + this.id; + hash = 67 * hash + this.idCaserne; + hash = 67 * hash + Objects.hashCode(this.nom); + hash = 67 * hash + Objects.hashCode(this.prenom); + hash = 67 * hash + this.statut; + hash = 67 * hash + this.typePers; + hash = 67 * hash + Objects.hashCode(this.mail); + hash = 67 * hash + Objects.hashCode(this.login); + hash = 67 * hash + Objects.hashCode(this.mdp); + hash = 67 * hash + Objects.hashCode(this.adresse); + hash = 67 * hash + Objects.hashCode(this.cp); + hash = 67 * hash + Objects.hashCode(this.ville); + hash = 67 * hash + this.bip; + hash = 67 * hash + this.nbGrade; + hash = 67 * hash + this.grade; + hash = 67 * hash + Objects.hashCode(this.commentaire); + hash = 67 * hash + this.idEmployeur; return hash; } @@ -201,12 +249,21 @@ public class Pompier { if (this.statut != other.statut) { return false; } - if (this.adrNo != other.adrNo) { + if (this.typePers != other.typePers) { + return false; + } + if (this.bip != other.bip) { + return false; + } + if (this.nbGrade != other.nbGrade) { return false; } if (this.grade != other.grade) { return false; } + if (this.idEmployeur != other.idEmployeur) { + return false; + } if (!Objects.equals(this.nom, other.nom)) { return false; } @@ -222,13 +279,13 @@ public class Pompier { if (!Objects.equals(this.mdp, other.mdp)) { return false; } - if (!Objects.equals(this.adrRue, other.adrRue)) { + if (!Objects.equals(this.adresse, other.adresse)) { return false; } - if (!Objects.equals(this.adrCP, other.adrCP)) { + if (!Objects.equals(this.cp, other.cp)) { return false; } - if (!Objects.equals(this.adrVille, other.adrVille)) { + if (!Objects.equals(this.ville, other.ville)) { return false; } if (!Objects.equals(this.commentaire, other.commentaire)) { @@ -239,9 +296,8 @@ public class Pompier { @Override public String toString() { - return "Pompier{" + "id=" + id + ", idCaserne=" + idCaserne + ", nom=" + nom + ", prenom=" + prenom + ", statut=" + statut + ", mail=" + mail + ", login=" + login + ", mdp=" + mdp + ", adrNo=" + adrNo + ", adrRue=" + adrRue + ", adrCP=" + adrCP + ", adrVille=" + adrVille + ", grade=" + grade + ", commentaire=" + commentaire + '}'; + return "Pompier{" + "id=" + id + ", idCaserne=" + idCaserne + ", nom=" + nom + ", prenom=" + prenom + ", statut=" + statut + ", typePers=" + typePers + ", mail=" + mail + ", login=" + login + ", mdp=" + mdp + ", adresse=" + adresse + ", cp=" + cp + ", ville=" + ville + ", bip=" + bip + ", nbGrade=" + nbGrade + ", grade=" + grade + ", commentaire=" + commentaire + ", idEmployeur=" + idEmployeur + '}'; } + - - -} +} \ No newline at end of file diff --git a/web/WEB-INF/accueilJSP.jsp b/web/WEB-INF/accueilJSP.jsp index 967095e..0331fc9 100644 --- a/web/WEB-INF/accueilJSP.jsp +++ b/web/WEB-INF/accueilJSP.jsp @@ -22,9 +22,4 @@ Affichage du message contenu dans l'objet controlForm de type AuthentifForm -->

${controlForm.getResultat()}


- - - - - - + From 92854fc1f9424854f68005c62d11931dc542a95d Mon Sep 17 00:00:00 2001 From: "clementine.desrucques" Date: Thu, 21 Oct 2021 16:43:59 +0200 Subject: [PATCH 4/4] --- src/java/com/test/beans/Pompier.java | 59 ++++++++++++++-------------- web/WEB-INF/CreaPompier.jsp | 15 +++++-- 2 files changed, 41 insertions(+), 33 deletions(-) diff --git a/src/java/com/test/beans/Pompier.java b/src/java/com/test/beans/Pompier.java index bb8e356..6fc0b9d 100644 --- a/src/java/com/test/beans/Pompier.java +++ b/src/java/com/test/beans/Pompier.java @@ -25,12 +25,12 @@ public class Pompier { private String cp; private String ville; private int bip; - private int nbGrade; + private int nbGardes; private int grade; private String commentaire; private int idEmployeur; - public Pompier(int id, int idCaserne, String nom, String prenom, int statut, int typePers, String mail, String login, String mdp, String adresse, String cp, String ville, int bip, int nbGrade, int grade, String commentaire, int idEmployeur) { + public Pompier(int id, int idCaserne, String nom, String prenom, int statut, int typePers, String mail, String login, String mdp, String adresse, String cp, String ville, int bip, int nbGardes, int grade, String commentaire, int idEmployeur) { this.id = id; this.idCaserne = idCaserne; this.nom = nom; @@ -44,13 +44,13 @@ public class Pompier { this.cp = cp; this.ville = ville; this.bip = bip; - this.nbGrade = nbGrade; + this.nbGardes = nbGardes; this.grade = grade; this.commentaire = commentaire; this.idEmployeur = idEmployeur; } - public Pompier(int idCaserne, String nom, String prenom, int statut, int typePers, String mail, String login, String mdp, String adresse, String cp, String ville, int bip, int nbGrade, int grade, String commentaire, int idEmployeur) { + public Pompier(int idCaserne, String nom, String prenom, int statut, int typePers, String mail, String login, String mdp, String adresse, String cp, String ville, int bip, int nbGardes, int grade, String commentaire, int idEmployeur) { this.idCaserne = idCaserne; this.nom = nom; this.prenom = prenom; @@ -63,7 +63,7 @@ public class Pompier { this.cp = cp; this.ville = ville; this.bip = bip; - this.nbGrade = nbGrade; + this.nbGardes = nbGardes; this.grade = grade; this.commentaire = commentaire; this.idEmployeur = idEmployeur; @@ -173,12 +173,12 @@ public class Pompier { this.bip = bip; } - public int getNbGrade() { - return nbGrade; + public int getNbGardes() { + return nbGardes; } - public void setNbGrade(int nbGrade) { - this.nbGrade = nbGrade; + public void setNbGardes(int nbGardes) { + this.nbGardes = nbGardes; } public int getGrade() { @@ -207,24 +207,24 @@ public class Pompier { @Override public int hashCode() { - int hash = 3; - hash = 67 * hash + this.id; - hash = 67 * hash + this.idCaserne; - hash = 67 * hash + Objects.hashCode(this.nom); - hash = 67 * hash + Objects.hashCode(this.prenom); - hash = 67 * hash + this.statut; - hash = 67 * hash + this.typePers; - hash = 67 * hash + Objects.hashCode(this.mail); - hash = 67 * hash + Objects.hashCode(this.login); - hash = 67 * hash + Objects.hashCode(this.mdp); - hash = 67 * hash + Objects.hashCode(this.adresse); - hash = 67 * hash + Objects.hashCode(this.cp); - hash = 67 * hash + Objects.hashCode(this.ville); - hash = 67 * hash + this.bip; - hash = 67 * hash + this.nbGrade; - hash = 67 * hash + this.grade; - hash = 67 * hash + Objects.hashCode(this.commentaire); - hash = 67 * hash + this.idEmployeur; + int hash = 7; + hash = 47 * hash + this.id; + hash = 47 * hash + this.idCaserne; + hash = 47 * hash + Objects.hashCode(this.nom); + hash = 47 * hash + Objects.hashCode(this.prenom); + hash = 47 * hash + this.statut; + hash = 47 * hash + this.typePers; + hash = 47 * hash + Objects.hashCode(this.mail); + hash = 47 * hash + Objects.hashCode(this.login); + hash = 47 * hash + Objects.hashCode(this.mdp); + hash = 47 * hash + Objects.hashCode(this.adresse); + hash = 47 * hash + Objects.hashCode(this.cp); + hash = 47 * hash + Objects.hashCode(this.ville); + hash = 47 * hash + this.bip; + hash = 47 * hash + this.nbGardes; + hash = 47 * hash + this.grade; + hash = 47 * hash + Objects.hashCode(this.commentaire); + hash = 47 * hash + this.idEmployeur; return hash; } @@ -255,7 +255,7 @@ public class Pompier { if (this.bip != other.bip) { return false; } - if (this.nbGrade != other.nbGrade) { + if (this.nbGardes != other.nbGardes) { return false; } if (this.grade != other.grade) { @@ -296,8 +296,9 @@ public class Pompier { @Override public String toString() { - return "Pompier{" + "id=" + id + ", idCaserne=" + idCaserne + ", nom=" + nom + ", prenom=" + prenom + ", statut=" + statut + ", typePers=" + typePers + ", mail=" + mail + ", login=" + login + ", mdp=" + mdp + ", adresse=" + adresse + ", cp=" + cp + ", ville=" + ville + ", bip=" + bip + ", nbGrade=" + nbGrade + ", grade=" + grade + ", commentaire=" + commentaire + ", idEmployeur=" + idEmployeur + '}'; + return "Pompier{" + "id=" + id + ", idCaserne=" + idCaserne + ", nom=" + nom + ", prenom=" + prenom + ", statut=" + statut + ", typePers=" + typePers + ", mail=" + mail + ", login=" + login + ", mdp=" + mdp + ", adresse=" + adresse + ", cp=" + cp + ", ville=" + ville + ", bip=" + bip + ", nbGardes=" + nbGardes + ", grade=" + grade + ", commentaire=" + commentaire + ", idEmployeur=" + idEmployeur + '}'; } + } \ No newline at end of file diff --git a/web/WEB-INF/CreaPompier.jsp b/web/WEB-INF/CreaPompier.jsp index 5ff4a9c..7e37b69 100644 --- a/web/WEB-INF/CreaPompier.jsp +++ b/web/WEB-INF/CreaPompier.jsp @@ -24,24 +24,31 @@



+ +







- -

- -

+ +

+



+ +

+ +





+ +