Merge origin/master

This commit is contained in:
clement.bouillot 2021-10-20 11:19:09 +02:00
commit b03ba20539
30 changed files with 3273 additions and 0 deletions

71
build.xml Normal file
View File

@ -0,0 +1,71 @@
<?xml version="1.0" encoding="UTF-8"?>
<!-- You may freely edit this file. See commented blocks below for -->
<!-- some examples of how to customize the build. -->
<!-- (If you delete it and reopen the project it will be recreated.) -->
<!-- By default, only the Clean and Build commands use this build script. -->
<!-- Commands such as Run, Debug, and Test only use this build script if -->
<!-- the Compile on Save feature is turned off for the project. -->
<!-- You can turn off the Compile on Save (or Deploy on Save) setting -->
<!-- in the project's Project Properties dialog box.-->
<project name="SDIS29" default="default" basedir=".">
<description>Builds, tests, and runs the project SDIS29.</description>
<import file="nbproject/build-impl.xml"/>
<!--
There exist several targets which are by default empty and which can be
used for execution of your tasks. These targets are usually executed
before and after some main targets. They are:
-pre-init: called before initialization of project properties
-post-init: called after initialization of project properties
-pre-compile: called before javac compilation
-post-compile: called after javac compilation
-pre-compile-single: called before javac compilation of single file
-post-compile-single: called after javac compilation of single file
-pre-compile-test: called before javac compilation of JUnit tests
-post-compile-test: called after javac compilation of JUnit tests
-pre-compile-test-single: called before javac compilation of single JUnit test
-post-compile-test-single: called after javac compilation of single JUunit test
-pre-dist: called before archive building
-post-dist: called after archive building
-post-clean: called after cleaning build products
-pre-run-deploy: called before deploying
-post-run-deploy: called after deploying
Example of pluging an obfuscator after the compilation could look like
<target name="-post-compile">
<obfuscate>
<fileset dir="${build.classes.dir}"/>
</obfuscate>
</target>
For list of available properties check the imported
nbproject/build-impl.xml file.
Other way how to customize the build is by overriding existing main targets.
The target of interest are:
init-macrodef-javac: defines macro for javac compilation
init-macrodef-junit: defines macro for junit execution
init-macrodef-debug: defines macro for class debugging
do-dist: archive building
run: execution of project
javadoc-build: javadoc generation
Example of overriding the target for project execution could look like
<target name="run" depends="<PROJNAME>-impl.jar">
<exec dir="bin" executable="launcher.exe">
<arg file="${dist.jar}"/>
</exec>
</target>
Notice that overridden target depends on jar target and not only on
compile target as regular run target does. Again, for list of available
properties which you can use check the target you are overriding in
nbproject/build-impl.xml file.
-->
</project>

Binary file not shown.

Binary file not shown.

Binary file not shown.

57
nbproject/ant-deploy.xml Normal file
View File

@ -0,0 +1,57 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
Licensed to the Apache Software Foundation (ASF) under one
or more contributor license agreements. See the NOTICE file
distributed with this work for additional information
regarding copyright ownership. The ASF licenses this file
to you under the Apache License, Version 2.0 (the
"License"); you may not use this file except in compliance
with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing,
software distributed under the License is distributed on an
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
KIND, either express or implied. See the License for the
specific language governing permissions and limitations
under the License.
-->
<project default="-deploy-ant" basedir=".">
<target name="-init" if="deploy.ant.enabled">
<property file="${deploy.ant.properties.file}"/>
<tempfile property="temp.module.folder" prefix="tomcat" destdir="${java.io.tmpdir}"/>
<unwar src="${deploy.ant.archive}" dest="${temp.module.folder}">
<patternset includes="META-INF/context.xml"/>
</unwar>
<xmlproperty file="${temp.module.folder}/META-INF/context.xml"/>
<delete dir="${temp.module.folder}"/>
</target>
<target name="-check-credentials" if="deploy.ant.enabled" depends="-init">
<fail message="Tomcat password has to be passed as tomcat.password property.">
<condition>
<not>
<isset property="tomcat.password"/>
</not>
</condition>
</fail>
</target>
<target name="-deploy-ant" if="deploy.ant.enabled" depends="-init,-check-credentials">
<echo message="Deploying ${deploy.ant.archive} to ${Context(path)}"/>
<taskdef name="deploy" classname="org.apache.catalina.ant.DeployTask"
classpath="${tomcat.home}/server/lib/catalina-ant.jar"/>
<deploy url="${tomcat.url}/manager" username="${tomcat.username}"
password="${tomcat.password}" path="${Context(path)}"
war="${deploy.ant.archive}"/>
<property name="deploy.ant.client.url" value="${tomcat.url}${Context(path)}"/>
</target>
<target name="-undeploy-ant" if="deploy.ant.enabled" depends="-init,-check-credentials">
<echo message="Undeploying ${Context(path)}"/>
<taskdef name="undeploy" classname="org.apache.catalina.ant.UndeployTask"
classpath="${tomcat.home}/server/lib/catalina-ant.jar"/>
<undeploy url="${tomcat.url}/manager" username="${tomcat.username}"
password="${tomcat.password}" path="${Context(path)}"/>
</target>
</project>

1434
nbproject/build-impl.xml Normal file

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,8 @@
build.xml.data.CRC32=fb8fe3ea
build.xml.script.CRC32=3bb75b60
build.xml.stylesheet.CRC32=1707db4f@1.86.0.1
# This file is used by a NetBeans-based IDE to track changes in generated files such as build-impl.xml.
# Do not edit this file. You may delete it but then the IDE will never regenerate such files for you.
nbproject/build-impl.xml.data.CRC32=fb8fe3ea
nbproject/build-impl.xml.script.CRC32=d5603c36
nbproject/build-impl.xml.stylesheet.CRC32=334708a0@1.86.0.1

View File

@ -0,0 +1,90 @@
annotation.processing.enabled=true
annotation.processing.enabled.in.editor=true
annotation.processing.processors.list=
annotation.processing.run.all.processors=true
annotation.processing.source.output=${build.generated.sources.dir}/ap-source-output
auxiliary.org-netbeans-modules-projectapi.jsf_2e_language=JSP
build.classes.dir=${build.web.dir}/WEB-INF/classes
build.classes.excludes=**/*.java,**/*.form
build.dir=build
build.generated.dir=${build.dir}/generated
build.generated.sources.dir=${build.dir}/generated-sources
build.test.classes.dir=${build.dir}/test/classes
build.test.results.dir=${build.dir}/test/results
build.web.dir=${build.dir}/web
build.web.excludes=${build.classes.excludes}
client.urlPart=/Accueil
compile.jsps=false
conf.dir=${source.root}/conf
debug.classpath=${build.classes.dir}:${javac.classpath}
debug.test.classpath=\
${run.test.classpath}
display.browser=true
# Files to be excluded from distribution war
dist.archive.excludes=
dist.dir=dist
dist.ear.war=${dist.dir}/${war.ear.name}
dist.javadoc.dir=${dist.dir}/javadoc
dist.war=${dist.dir}/${war.name}
endorsed.classpath=\
${libs.javaee-endorsed-api-7.0.classpath}
excludes=
file.reference.jakarta.servlet.jsp.jstl-2.0.0.jar=D:/Downloads/jakarta.servlet.jsp.jstl-2.0.0.jar
file.reference.jakarta.servlet.jsp.jstl-api-2.0.0.jar=D:/Downloads/jakarta.servlet.jsp.jstl-api-2.0.0.jar
file.reference.mysql-connector-java-8.0.26.jar=C:/Program Files (x86)/MySQL/Connector J 8.0/mysql-connector-java-8.0.26.jar
includes=**
j2ee.compile.on.save=true
j2ee.copy.static.files.on.save=true
j2ee.deploy.on.save=true
j2ee.platform=1.7-web
j2ee.platform.classpath=${j2ee.server.domain}/lib/annotations-api.jar:${j2ee.server.domain}/lib/catalina-ant.jar:${j2ee.server.domain}/lib/catalina-ha.jar:${j2ee.server.domain}/lib/catalina-ssi.jar:${j2ee.server.domain}/lib/catalina-storeconfig.jar:${j2ee.server.domain}/lib/catalina-tribes.jar:${j2ee.server.domain}/lib/catalina.jar:${j2ee.server.domain}/lib/ecj-4.20.jar:${j2ee.server.domain}/lib/el-api.jar:${j2ee.server.domain}/lib/jakartaee-migration-1.0.0-shaded.jar:${j2ee.server.domain}/lib/jasper-el.jar:${j2ee.server.domain}/lib/jasper.jar:${j2ee.server.domain}/lib/jaspic-api.jar:${j2ee.server.domain}/lib/jsp-api.jar:${j2ee.server.domain}/lib/servlet-api.jar:${j2ee.server.domain}/lib/tomcat-api.jar:${j2ee.server.domain}/lib/tomcat-coyote.jar:${j2ee.server.domain}/lib/tomcat-dbcp.jar:${j2ee.server.domain}/lib/tomcat-i18n-cs.jar:${j2ee.server.domain}/lib/tomcat-i18n-de.jar:${j2ee.server.domain}/lib/tomcat-i18n-es.jar:${j2ee.server.domain}/lib/tomcat-i18n-fr.jar:${j2ee.server.domain}/lib/tomcat-i18n-ja.jar:${j2ee.server.domain}/lib/tomcat-i18n-ko.jar:${j2ee.server.domain}/lib/tomcat-i18n-pt-BR.jar:${j2ee.server.domain}/lib/tomcat-i18n-ru.jar:${j2ee.server.domain}/lib/tomcat-i18n-zh-CN.jar:${j2ee.server.domain}/lib/tomcat-jdbc.jar:${j2ee.server.domain}/lib/tomcat-jni.jar:${j2ee.server.domain}/lib/tomcat-util-scan.jar:${j2ee.server.domain}/lib/tomcat-util.jar:${j2ee.server.domain}/lib/tomcat-websocket.jar:${j2ee.server.domain}/lib/websocket-api.jar
j2ee.server.type=Tomcat
jar.compress=false
javac.classpath=\
${file.reference.mysql-connector-java-8.0.26.jar}:\
${file.reference.jakarta.servlet.jsp.jstl-2.0.0.jar}:\
${file.reference.jakarta.servlet.jsp.jstl-api-2.0.0.jar}
# Space-separated list of extra javac options
javac.compilerargs=
javac.debug=true
javac.deprecation=false
javac.processorpath=\
${javac.classpath}
javac.source=1.7
javac.target=1.7
javac.test.classpath=\
${javac.classpath}:\
${build.classes.dir}
javac.test.processorpath=\
${javac.test.classpath}
javadoc.additionalparam=
javadoc.author=false
javadoc.encoding=${source.encoding}
javadoc.noindex=false
javadoc.nonavbar=false
javadoc.notree=false
javadoc.preview=true
javadoc.private=false
javadoc.splitindex=true
javadoc.use=true
javadoc.version=false
javadoc.windowtitle=
lib.dir=${web.docbase.dir}/WEB-INF/lib
persistence.xml.dir=${conf.dir}
platform.active=default_platform
resource.dir=setup
run.test.classpath=\
${javac.test.classpath}:\
${build.test.classes.dir}
# Space-separated list of JVM arguments used when running a class with a main method or a unit test
# (you may also define separate properties like run-sys-prop.name=value instead of -Dname=value):
runmain.jvmargs=
source.encoding=UTF-8
source.root=src
src.dir=${source.root}/java
test.src.dir=test
war.content.additional=
war.ear.name=${war.name}
war.name=SDIS29.war
web.docbase.dir=web
webinf.dir=web/WEB-INF

31
nbproject/project.xml Normal file
View File

@ -0,0 +1,31 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://www.netbeans.org/ns/project/1">
<type>org.netbeans.modules.web.project</type>
<configuration>
<data xmlns="http://www.netbeans.org/ns/web-project/3">
<name>SDIS29</name>
<minimum-ant-version>1.6.5</minimum-ant-version>
<web-module-libraries>
<library dirs="200">
<file>${file.reference.mysql-connector-java-8.0.26.jar}</file>
<path-in-war>WEB-INF/lib</path-in-war>
</library>
<library dirs="200">
<file>${file.reference.jakarta.servlet.jsp.jstl-2.0.0.jar}</file>
<path-in-war>WEB-INF/lib</path-in-war>
</library>
<library dirs="200">
<file>${file.reference.jakarta.servlet.jsp.jstl-api-2.0.0.jar}</file>
<path-in-war>WEB-INF/lib</path-in-war>
</library>
</web-module-libraries>
<web-module-additional-libraries/>
<source-roots>
<root id="src.dir"/>
</source-roots>
<test-roots>
<root id="test.src.dir"/>
</test-roots>
</data>
</configuration>
</project>

2
src/conf/MANIFEST.MF Normal file
View File

@ -0,0 +1,2 @@
Manifest-Version: 1.0

View File

@ -0,0 +1,155 @@
/*
* ClientMysql.java
*/
package bdd;
import com.test.beans.Pompier;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import java.util.ArrayList;
import java.util.logging.Level;
import java.util.logging.Logger;
/**
*
* @author Dominique_2
*/
public class ClientMysql {
private Connection theConnection;
private Pompier unClient;
/**
* Constructeur
*/
public ClientMysql() {
theConnection = Connexion.getConnect("localhost", //s erveur
"bdclient", // base de données
"adminBDClient",// user
"mdpBDClient"); // mot de passe ClientMysql() {
}
/**
* Recherche de tous les clients
* @return collection de clients
*/
public ArrayList<Pompier> readAll() {
ArrayList<Pompier> lesClients = new ArrayList<>();
try {
Statement stmt = theConnection.createStatement();
ResultSet resultQ = null;
resultQ = stmt.executeQuery("SELECT * FROM client");
while (resultQ.next()) {
unClient = new Pompier(resultQ.getInt("id"),
resultQ.getString("civilite"),
resultQ.getString("nom"),
resultQ.getString("prenom"),
resultQ.getString("mdp"),
resultQ.getInt("adrno"),
resultQ.getString("adrrue"),
resultQ.getString("adrville"),
resultQ.getString("adrcp"),
resultQ.getString("adrmail"),
resultQ.getString("tel"),
resultQ.getString("dateNais"));
lesClients.add(unClient);
}
resultQ.close();
stmt.close();
//theConnection.close();
} catch (SQLException ex) {
System.out.println("SQLException : " + ex.getMessage());
System.out.println("SQLState : " + ex.getSQLState());
System.out.println("Code erreur : " + ex.getErrorCode());
}
return lesClients;
}
/**
* Creation du client passé en paramètre dans la table client
* Requête non préparée
* @param c objet de type Pompier (sans identifiant)
* @return int : id du client créé
*/
public int create(Pompier c) {
int id = -1;
try {
Statement stmt = theConnection.createStatement();
int status = stmt.executeUpdate(
"INSERT INTO client (civilite, nom, prenom, mdp, adrno, adrrue, adrville, adrcp, adrmail, tel, dateNais) "
+ "VALUES ('" + c.getCivilite() + "', '"
+ c.getNom() + "', '"
+ c.getPrenom() + "', '"
+ c.getMdp() + "', "
+ c.getAdrNo() + ", '"
+ c.getAdrRue() + "', '"
+ c.getAdrCP() + "', '"
+ c.getAdrVille() + "', '"
+ c.getAdrmail()+ "', '"
+ c.getTel()+ "', '"
+ c.getDateNais() + "');",
Statement.RETURN_GENERATED_KEYS);
// Recherche de l'identifiant du client créé
if (status > 0) {
ResultSet result = stmt.getGeneratedKeys();
if (result.first()) {
id = result.getInt(1);
}
}
} catch (SQLException ex) {
System.out.println("SQLException : " + ex.getMessage());
System.out.println("SQLState : " + ex.getSQLState());
System.out.println("Code erreur : " + ex.getErrorCode());
}
return id;
}
/**
* Creation du client passé en paramètre dans la table client
* Requête préparée
* @param c objet de type Pompier (sans identifiant)
* @return int : id du client créé
*/
public int createRP(Pompier c) {
int id = -1;
try {
PreparedStatement stmt = null;
String sql = "INSERT INTO client (civilite, nom, prenom, mdp, adrno, adrrue, adrville, adrcp, adrmail, tel, dateNais) "
+ "VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?);";
stmt = theConnection.prepareStatement(sql, Statement.RETURN_GENERATED_KEYS);
stmt.setString(1, c.getCivilite());
stmt.setString(2, c.getNom());
stmt.setString(3, c.getPrenom());
stmt.setString(4, c.getMdp());
stmt.setInt(5, c.getAdrNo());
stmt.setString(6, c.getAdrRue());
stmt.setString(7, c.getAdrCP());
stmt.setString(8, c.getAdrVille());
stmt.setString(9, c.getAdrmail());
stmt.setString(10, c.getTel());
stmt.setString(11, c.getDateNais());
System.out.println("Requête : " + stmt.toString());
int status = stmt.executeUpdate();
// Recherche de l'identifiant du client créé
if (status > 0) {
ResultSet result = stmt.getGeneratedKeys();
if (result.first()) {
id = result.getInt(1);
}
}
} catch (SQLException ex) {
System.out.println("SQLException : " + ex.getMessage());
System.out.println("SQLState : " + ex.getSQLState());
System.out.println("Code erreur : " + ex.getErrorCode());
}
return id;
}
}

View File

@ -0,0 +1,62 @@
package bdd;
/*
Connexion.java
Classe permettant d'établir une connexion avec une base de données mySQL
*/
import java.sql.Connection;
import java.sql.DriverManager;
public class Connexion {
private static Connection connect; // Variable de connexion
/**
* Constructeur
* @param serveur nom du serveur, localhost si local
* @param bdd nom de la base de données
* @param nomUtil nom utilisateur
* @param mdp mot de passe lié à l'utilisateur
*/
private Connexion(String serveur, String bdd, String nomUtil, String mdp) {
try {
// 1. Chargement du driver
//Class.forName("com.mysql.jdbc.Driver");
Class.forName("com.mysql.cj.jdbc.Driver");
System.out.println("Driver accessible");
// 2. Initialisation des paramètres de connexion
String host = serveur; // Serveur de bd
String dbname = bdd; // Nom bd
String url = "jdbc:mysql://" + host + "/" + dbname; // url de connexion
//url += "?autoReconnect=true"; // Ajout 26/09/2021
System.out.println("url : "+url);
String user = nomUtil; // nom du user
System.out.println("nomUtil : "+nomUtil);
String passwd = mdp; // mot de passe
System.out.println("mdp : "+mdp);
// 3. Connexion
connect = (Connection) DriverManager.getConnection(url, user, passwd);
System.out.println("Connexion réussie !");
} catch (Exception e) {
e.printStackTrace();
}
}
/**
* Retourne la connection établie (Création d'une connection si elle n'existe pas)
* @param serveur nom du serveur, localhost si local
* @param bdd nom de la base de données
* @param nomUtil nom utilisateur
* @param mdp mot de passe lié à l'utilisateur
* @return connection établie
*/
public static Connection getConnect(String serveur, String bdd, String nomUtil, String mdp) {
System.out.println("getConnect");
if (connect == null) {
new Connexion(serveur, bdd, nomUtil, mdp);
}
return connect;
}
}

View File

@ -0,0 +1,291 @@
/*
* Bean Pompier
*/
package com.test.beans;
import java.util.Objects;
/**
*
* @author Clément B
*/
public class Pompier {
private int id;
private int idCaserne;
private String nom;
private String prenom;
private String statut;
private int typePers;
private String mail;
private String login;
private String mdp;
private String adresse;
private String cp;
private String ville;
private int bip;
private int nbGardes;
private int grade;
private String commentaire;
private String dateEnreg;
private String dateModif;
private int idEquipe;
public Pompier() {
}
public int getId() {
return id;
}
public void setId(int id) {
this.id = id;
}
public int getIdCaserne() {
return idCaserne;
}
public void setIdCaserne(int idCaserne) {
this.idCaserne = idCaserne;
}
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 getStatut() {
return statut;
}
public void setStatut(String statut) {
this.statut = statut;
}
public int getTypePers() {
return typePers;
}
public void setTypePers(int typePers) {
this.typePers = typePers;
}
public String getMail() {
return mail;
}
public void setMail(String mail) {
this.mail = mail;
}
public String getLogin() {
return login;
}
public void setLogin(String login) {
this.login = login;
}
public String getMdp() {
return mdp;
}
public void setMdp(String mdp) {
this.mdp = mdp;
}
public String getAdresse() {
return adresse;
}
public void setAdresse(String adresse) {
this.adresse = adresse;
}
public String getCp() {
return cp;
}
public void setCp(String cp) {
this.cp = cp;
}
public String getVille() {
return ville;
}
public void setVille(String dateNais) {
this.ville = dateNais;
}
public int getBip() {
return bip;
}
public void setBip(int bip) {
this.bip = bip;
}
public int getNbGardes() {
return nbGardes;
}
public void setNbGardes(int nbGardes) {
this.nbGardes = nbGardes;
}
public int getGrade() {
return grade;
}
public void setGrade(int grade) {
this.grade = grade;
}
public String getCommentaire() {
return commentaire;
}
public void setCommentaire(String commentaire) {
this.commentaire = commentaire;
}
public String getDateEnreg() {
return dateEnreg;
}
public void setDateEnreg(String dateEnreg) {
this.dateEnreg = dateEnreg;
}
public String getDateModif() {
return dateModif;
}
public void setDateModif(String dateModif) {
this.dateModif = dateModif;
}
public int getIdEquipe() {
return idEquipe;
}
public void setIdEquipe(int idEquipe) {
this.idEquipe = idEquipe;
}
@Override
public int hashCode() {
int hash = 7;
hash = 59 * hash + this.id;
hash = 59 * hash + Objects.hashCode(this.idCaserne);
hash = 59 * hash + Objects.hashCode(this.nom);
hash = 59 * hash + Objects.hashCode(this.prenom);
hash = 59 * hash + Objects.hashCode(this.statut);
hash = 59 * hash + this.typePers;
hash = 59 * hash + Objects.hashCode(this.mail);
hash = 59 * hash + Objects.hashCode(this.login);
hash = 59 * hash + Objects.hashCode(this.mdp);
hash = 59 * hash + Objects.hashCode(this.adresse);
hash = 59 * hash + Objects.hashCode(this.cp);
hash = 59 * hash + Objects.hashCode(this.ville);
hash = 59 * hash + Objects.hashCode(this.bip);
hash = 59 * hash + this.nbGardes;
hash = 59 * hash + this.grade;
hash = 59 * hash + Objects.hashCode(this.commentaire);
hash = 59 * hash + Objects.hashCode(this.dateEnreg);
hash = 59 * hash + Objects.hashCode(this.dateModif);
hash = 59 * hash + this.idEquipe;
return hash;
}
@Override
public boolean equals(Object obj) {
if (this == obj) {
return true;
}
if (obj == null) {
return false;
}
if (getClass() != obj.getClass()) {
return false;
}
final Pompier other = (Pompier) obj;
if (this.id != other.id) {
return false;
}
if (this.typePers != other.typePers) {
return false;
}
if (this.nbGardes != other.nbGardes) {
return false;
}
if (this.grade != other.grade) {
return false;
}
if (this.idEquipe != other.idEquipe) {
return false;
}
if (!Objects.equals(this.idCaserne, other.idCaserne)) {
return false;
}
if (!Objects.equals(this.nom, other.nom)) {
return false;
}
if (!Objects.equals(this.prenom, other.prenom)) {
return false;
}
if (!Objects.equals(this.statut, other.statut)) {
return false;
}
if (!Objects.equals(this.mail, other.mail)) {
return false;
}
if (!Objects.equals(this.login, other.login)) {
return false;
}
if (!Objects.equals(this.mdp, other.mdp)) {
return false;
}
if (!Objects.equals(this.adresse, other.adresse)) {
return false;
}
if (!Objects.equals(this.cp, other.cp)) {
return false;
}
if (!Objects.equals(this.ville, other.ville)) {
return false;
}
if (!Objects.equals(this.bip, other.bip)) {
return false;
}
if (!Objects.equals(this.commentaire, other.commentaire)) {
return false;
}
if (!Objects.equals(this.dateEnreg, other.dateEnreg)) {
return false;
}
if (!Objects.equals(this.dateModif, other.dateModif)) {
return false;
}
return true;
}
@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 + ", nbGardes=" + nbGardes + ", grade=" + grade + ", commentaire=" + commentaire + ", dateEnreg=" + dateEnreg + ", dateModif=" + dateModif + ", idEquipe=" + idEquipe + '}';
}
}

View File

@ -0,0 +1,70 @@
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package com.test.beans;
import java.util.Objects;
/**
*
* @author Dominique_2
*/
public class User {
private String pseudo;
private String mdp;
public User(String pseudo, String mdp) {
this.pseudo = pseudo;
this.mdp = mdp;
}
public String getPseudo() {
return pseudo;
}
public void setPseudo(String pseudo) {
this.pseudo = pseudo;
}
public String getMdp() {
return mdp;
}
public void setMdp(String mdp) {
this.mdp = mdp;
}
@Override
public int hashCode() {
int hash = 7;
hash = 67 * hash + Objects.hashCode(this.pseudo);
hash = 67 * hash + Objects.hashCode(this.mdp);
return hash;
}
@Override
public boolean equals(Object obj) {
if (this == obj) {
return true;
}
if (obj == null) {
return false;
}
if (getClass() != obj.getClass()) {
return false;
}
final User other = (User) obj;
if (!Objects.equals(this.pseudo, other.pseudo)) {
return false;
}
if (!Objects.equals(this.mdp, other.mdp)) {
return false;
}
return true;
}
}

View File

@ -0,0 +1,259 @@
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package com.test.filter;
import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpSession;
import java.io.IOException;
import java.io.PrintStream;
import java.io.PrintWriter;
import java.io.StringWriter;
import jakarta.servlet.Filter;
import jakarta.servlet.FilterChain;
import jakarta.servlet.FilterConfig;
import jakarta.servlet.ServletException;
import jakarta.servlet.ServletRequest;
import jakarta.servlet.ServletResponse;
/**
*
* @author nathan.balducci
*/
public class AuthentifFiltrer implements Filter {
private static final boolean debug = true;
// The filter configuration object we are associated with. If
// this value is null, this filter instance is not currently
// configured.
private FilterConfig filterConfig = null;
public AuthentifFiltrer() {
}
private void doBeforeProcessing(ServletRequest request, ServletResponse response)
throws IOException, ServletException {
if (debug) {
log("AuthentifFiltrer:DoBeforeProcessing");
}
// Write code here to process the request and/or response before
// the rest of the filter chain is invoked.
// For example, a logging filter might log items on the request object,
// such as the parameters.
/*
for (Enumeration en = request.getParameterNames(); en.hasMoreElements(); ) {
String name = (String)en.nextElement();
String values[] = request.getParameterValues(name);
int n = values.length;
StringBuffer buf = new StringBuffer();
buf.append(name);
buf.append("=");
for(int i=0; i < n; i++) {
buf.append(values[i]);
if (i < n-1)
buf.append(",");
}
log(buf.toString());
}
*/
}
private void doAfterProcessing(ServletRequest request, ServletResponse response)
throws IOException, ServletException {
if (debug) {
log("AuthentifFiltrer:DoAfterProcessing");
}
// Write code here to process the request and/or response after
// the rest of the filter chain is invoked.
// For example, a logging filter might log the attributes on the
// request object after the request has been processed.
/*
for (Enumeration en = request.getAttributeNames(); en.hasMoreElements(); ) {
String name = (String)en.nextElement();
Object value = request.getAttribute(name);
log("attribute: " + name + "=" + value.toString());
}
*/
// For example, a filter might append something to the response.
/*
PrintWriter respOut = new PrintWriter(response.getWriter());
respOut.println("<P><B>This has been appended by an intrusive filter.</B>");
*/
}
/**
*
* @param request The servlet request we are processing
* @param response The servlet response we are creating
* @param chain The filter chain we are processing
*
* @exception IOException if an input/output error occurs
* @exception ServletException if a servlet error occurs
*/
public void doFilter(ServletRequest request, ServletResponse response,
FilterChain chain)
throws IOException, ServletException {
//
// if (debug) {
// log("AuthentifFiltrer:doFilter()");
// }
//
// doBeforeProcessing(request, response);
//
// Throwable problem = null;
// try {
// chain.doFilter(request, response);
// } catch (Throwable t) {
// // If an exception is thrown somewhere down the filter chain,
// // we still want to execute our after processing, and then
// // rethrow the problem after that.
// problem = t;
// t.printStackTrace();
// }
//
// doAfterProcessing(request, response);
//
// // If there was a problem, we want to rethrow it if it is
// // a known type, otherwise log it.
// if (problem != null) {
// if (problem instanceof ServletException) {
// throw (ServletException) problem;
// }
// if (problem instanceof IOException) {
// throw (IOException) problem;
// }
// sendProcessingError(problem, response);
// }
// Cast de l'objet request
HttpServletRequest requete = (HttpServletRequest) request;
// Pas de filtrage des css, des images, des js
String chemin =
requete.getRequestURI().substring(requete.getContextPath().length());
if (chemin.startsWith("/css") || chemin.startsWith("/images") ||
chemin.startsWith("/js")) {
chain.doFilter(request, response);
return;
}
// Récupération de la session
HttpSession maSession = requete.getSession();
// Récupération du booléen d'authentification
boolean authentificationOK = false;
if (maSession.getAttribute("isAuthentified") != null) {
authentificationOK = (boolean)
maSession.getAttribute("isAuthentified");
}
if (authentificationOK) {
// Poursuite sans problème
chain.doFilter(request, response);
} else {
// retour vers la page d'authentification
request.getRequestDispatcher("Accueil").forward(request, response);
}
}
/**
* Return the filter configuration object for this filter.
*/
public FilterConfig getFilterConfig() {
return (this.filterConfig);
}
/**
* Set the filter configuration object for this filter.
*
* @param filterConfig The filter configuration object
*/
public void setFilterConfig(FilterConfig filterConfig) {
this.filterConfig = filterConfig;
}
/**
* Destroy method for this filter
*/
public void destroy() {
}
/**
* Init method for this filter
*/
public void init(FilterConfig filterConfig) {
this.filterConfig = filterConfig;
if (filterConfig != null) {
if (debug) {
log("AuthentifFiltrer:Initializing filter");
}
}
}
/**
* Return a String representation of this object.
*/
@Override
public String toString() {
if (filterConfig == null) {
return ("AuthentifFiltrer()");
}
StringBuffer sb = new StringBuffer("AuthentifFiltrer(");
sb.append(filterConfig);
sb.append(")");
return (sb.toString());
}
private void sendProcessingError(Throwable t, ServletResponse response) {
String stackTrace = getStackTrace(t);
if (stackTrace != null && !stackTrace.equals("")) {
try {
response.setContentType("text/html");
PrintStream ps = new PrintStream(response.getOutputStream());
PrintWriter pw = new PrintWriter(ps);
pw.print("<html>\n<head>\n<title>Error</title>\n</head>\n<body>\n"); //NOI18N
// PENDING! Localize this for next official release
pw.print("<h1>The resource did not process correctly</h1>\n<pre>\n");
pw.print(stackTrace);
pw.print("</pre></body>\n</html>"); //NOI18N
pw.close();
ps.close();
response.getOutputStream().close();
} catch (Exception ex) {
}
} else {
try {
PrintStream ps = new PrintStream(response.getOutputStream());
t.printStackTrace(ps);
ps.close();
response.getOutputStream().close();
} catch (Exception ex) {
}
}
}
public static String getStackTrace(Throwable t) {
String stackTrace = null;
try {
StringWriter sw = new StringWriter();
PrintWriter pw = new PrintWriter(sw);
t.printStackTrace(pw);
pw.close();
sw.close();
stackTrace = sw.getBuffer().toString();
} catch (Exception ex) {
}
return stackTrace;
}
public void log(String msg) {
filterConfig.getServletContext().log(msg);
}
}

View File

@ -0,0 +1,57 @@
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package com.test.forms;
import com.test.beans.User;
import jakarta.servlet.http.HttpServletRequest;
import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import java.util.ArrayList;
import java.util.logging.Level;
import java.util.logging.Logger;
//import java.sql.Connection;
/**
*
* @author Dominique_2
*/
public class AuthentifForm {
private String resultat;
public String getResultat() {
return resultat;
}
public void setResultat(String resultat) {
this.resultat = resultat;
}
/**
* Contôle si les paramètres ztPseudo et ztMDP passé dans request
* correspondent à ceux de l'addministrateur Mise à jour de l'attribut
* resultat
*
* @param request
* @return true is ok, false sinon
*/
public boolean controlerAdmin(HttpServletRequest request) {
/* Comparaison entre l'utilisateur admin et un utilisateur créé
avec le pseudo et le mdp saisi */
User admin = new User("Lovelace", "Ada");
User userSaisi = new User( request.getParameter("ztPseudo"),
request.getParameter("ztMDP"));
boolean isAdmin = userSaisi.equals(admin);
// Mise à jour de l'attribut resultat
setResultat(isAdmin ? "Vous êtes administrateur" : "Vous n'êtes pas administrateur");
return isAdmin;
}
}

View File

@ -0,0 +1,70 @@
/*
* NouveauPompierForm.java
*/
package com.test.forms;
import bdd.ClientMysql;
import com.mysql.cj.util.StringUtils;
import com.test.beans.Pompier;
import jakarta.servlet.http.HttpServletRequest;
import java.util.Enumeration;
/**
*
* @author domin
*/
public class NouveauPompierForm {
String message="";
public int verifNouveauClient(HttpServletRequest request) {
// Contrôle du no de rue qui doit être numérique
String noRueString = request.getParameter("ztNoRue");
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
Enumeration lesNoms = request.getParameterNames();
int erreur = 0;
while (erreur ==0 && lesNoms.hasMoreElements()) {
Object paramObjet=lesNoms.nextElement();
String param=(String)paramObjet;
String value=request.getParameter(param);
if (value.contains("<")) {
message = "Veullez recommencer votre saisie, une anomalie sur une zone de saisie a été détectée ";
erreur=1;
}
}
if (erreur > 0) return -1;
// Creation d'un objet de type Pompier avec les données transmises
Pompier unClient = new Pompier(request.getParameter("btrCivilite"),
request.getParameter("ztNom"),
request.getParameter("ztPrenom"),
request.getParameter("ztPwd"),
noRue,
request.getParameter("ztRue"),
request.getParameter("ztCP"),
request.getParameter("ztVille"),
request.getParameter("ztMail"),
request.getParameter("ztTel"),
request.getParameter("ztDateNais"));
ClientMysql cm = new ClientMysql();
int idClient = cm.createRP(unClient); // Requête préparée
if (idClient == -1) {
message = "Erreur lors de la création du client";
}
return idClient;
}
public String getMessage() {
return message;
}
}

View File

@ -0,0 +1,105 @@
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package com.test.servlets;
import com.test.forms.AuthentifForm;
import java.io.IOException;
import java.io.PrintWriter;
import jakarta.servlet.ServletException;
import jakarta.servlet.http.HttpServlet;
import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletResponse;
import jakarta.servlet.http.HttpSession;
/**
*
* @author Dominique_2
*/
public class AccueilServlet 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 AccueilServlet</title>");
out.println("</head>");
out.println("<body>");
out.println("<h1>Servlet AccueilServlet 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 {
//processRequest(request, response);
HttpSession maSession = request.getSession();
maSession.removeAttribute("isAuthentified");
System.out.println("****blablabla****");
getServletContext().getRequestDispatcher("/WEB-INF/accueilJSP.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 {
// Création de l'objet leControle de type AuthentifForm
AuthentifForm leControle = new AuthentifForm();
// Appel de la méthode controlerAdmin
boolean isAdmin = leControle.controlerAdmin(request);
// Création de 2 attributs de requête (isAdmin et leControle)
request.setAttribute("isAdmin", isAdmin);
request.setAttribute("controlForm", leControle);
HttpSession maSession = request.getSession();
maSession.setAttribute("isAuthentified", true);
// Affichage de la JSP
getServletContext().getRequestDispatcher("/WEB-INF/accueilJSP.jsp")
.forward(request, response);
}
/**
* Returns a short description of the servlet.
*
* @return a String containing servlet description
*/
@Override
public String getServletInfo() {
return "Short description";
}// </editor-fold>
}

View File

@ -0,0 +1,94 @@
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package com.test.servlets;
import bdd.ClientMysql;
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 Dominique_2
*/
@WebServlet(name = "ListeServlet", urlPatterns = {"/ListeClients"})
public class ListeServlet 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 ListeServlet</title>");
out.println("</head>");
out.println("<body>");
out.println("<h1>Servlet ListeServlet 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 {
//processRequest(request, response);
// Recherche de tous les clients et ajout dans un attribut de l'objet request
ClientMysql clientMs = new ClientMysql();
request.setAttribute("lesClients", clientMs.readAll());
getServletContext().getRequestDispatcher("/WEB-INF/listeJSP.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>
}

View File

@ -0,0 +1,115 @@
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package com.test.servlets;
import com.test.forms.NouveauPompierForm;
import java.io.IOException;
import java.io.PrintWriter;
import jakarta.servlet.ServletException;
import jakarta.servlet.http.HttpServlet;
import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletResponse;
import jakarta.servlet.http.HttpSession;
import java.util.ArrayList;
/**
*
* @author Dominique_2
*/
public class NouveauServlet 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 NouveauServlet</title>");
out.println("</head>");
out.println("<body>");
out.println("<h1>Servlet NouveauServlet 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 {
//processRequest(request, response);
getServletContext().getRequestDispatcher("/WEB-INF/nouveauJSP.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 {
NouveauPompierForm nvf = new NouveauPompierForm();
int idClient = nvf.verifNouveauClient(request);
request.setAttribute("idClient", idClient);
request.setAttribute("message", nvf.getMessage());
if(idClient != -1) {
//Ajout du no du client créé, dans une collection d'entiers stockée en session
//1, Récupération de la session :
HttpSession maSession = request.getSession();
//2, Récupération de la collection des clients si elle existe, création sinon :
ArrayList<Integer> lesNouveauxClients = (ArrayList<Integer>)
maSession.getAttribute("lesNvxClients");
if(lesNouveauxClients == null) {
lesNouveauxClients = new ArrayList<>();
}
//3, Ajout du no du client créé dans la collection :
lesNouveauxClients.add(idClient);
//4, MAJ de la session
maSession.setAttribute("lesNvxClients", lesNouveauxClients);
}
getServletContext().getRequestDispatcher("/WEB-INF/nouveauJSP.jsp").forward(request, response);
HttpSession maSession = request.getSession();
// String maChaine = null;
// if(maSession.getAttribute("monAttribut" != null) {
// String maChaine = (String) maSession.getAttribute("monAttribut");
// }
}
/**
* Returns a short description of the servlet.
*
* @return a String containing servlet description
*/
@Override
public String getServletInfo() {
return "Short description";
}// </editor-fold>
}

2
web/META-INF/context.xml Normal file
View File

@ -0,0 +1,2 @@
<?xml version="1.0" encoding="UTF-8"?>
<Context path="/SDIS29"/>

View File

@ -0,0 +1,79 @@
<%@include file = "jspf/enteteJSPF.jspf" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@page import="com.test.forms.AuthentifForm" %>
<!-- Message de bienvenue personnalisé -->
<p>Bienvenue <c:out value="${param.ztPseudo}" /> sur la nouvelle application de gestion des clients</p>
${empty param.ztPseudo ? "Veuillez vous authentifier" : "Authentification réussie"}
<!-- Affichage du formulaire si l'utilisateur ne s'est pas encore authentifié -->
<c:choose>
<c:when test="${empty param.ztPseudo}">
<fieldset>
<legend>Authentification</legend>
<form method="POST" action="Accueil">
<input type="text" name="ztPseudo" placeholder="Pseudo" /><br /><!-- comment -->
<input type="password" name="ztMDP" placeholder="Mot de passe" /><br /><br />
<input type="submit" value="Valider" />
</form>
</fieldset>
</c:when>
<c:otherwise>
<!-- Si l'utilisateur s'est authentifié,
Affichage du message contenu dans l'objet controlForm de type AuthentifForm -->
<p>${controlForm.getResultat()}</p>
</c:otherwise>
</c:choose>
<br />
<!-- Affichage des 3 liens htpertexte -->
<%@include file="jspf/menuJSPF.jspf" %>
<!-- Test EL Expression Langage -->
<!-- Test avec formule de calcul -->
<h2>Tests divers </h2>F
${ 10 / 4} <br />
<p>Test avec EL et JSTL </p>
<p>ztPseudo : ${param.ztPseudo}</p>
<p>isAdmin : ${isAdmin}</p>
<p>Message reçu : ${controlForm.getResultat()}</p>
<c:out value="Test jstl : ${controlForm.getResultat()}" />
<c:out value="${controlForm.getResultat()}">
Je ne sais pas encore si vous êtes administrateur
</c:out>
<c:set var="message" value="Hello" scope="request" />
<p>Voici le message : ${message} </p>
<p> Test sur controlForm :
${empty controlForm.getResultat() ? "" : controlForm.getResultat()}
</p>
<c:out value="${empty param.ztPseudo ? 'none' : param.ztPseudo += ' enabled'}" />
<c:set var="langue" scope="request">
<c:out value="${param.lang}" default="français" />
</c:set>
<p>Langue : ${langue} </p>
<c:if test="${12 > 7}" var="resultatTest" scope="page" >
Test positif
</c:if>
<p> Résultat du test : ${resultatTest}</p>
<c:forEach var="i" begin="0" end="5" step="1" >
Instructions à répéter (html, ou jstl)- ${i} <br />
</c:forEach>
Voici les controles : <br />
<c:forEach items="${lesControles}" var="unControle" >
${unControle.toString()} <br />
</c:forEach>
</body>
</html>

View File

@ -0,0 +1,16 @@
<%-- any content can be specified here e.g.: --%>
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<%--
Document : newjsp
Created on : 18 sept. 2021, 15:34:04
Author : Dominique_2
--%>
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Gestion des clients</title>
</head>
<body>
<h1>Gestion des clients</h1>

View File

@ -0,0 +1,7 @@
<%-- any content can be specified here e.g.: --%>
<%@ page pageEncoding="UTF-8" %>
<nav>
<a href ="Accueil">Accueil</a>
<a href="NouveauClient">Création d'un nouveau client</a>
<a href="ListeClients">Liste des clients</a>
</nav>

48
web/WEB-INF/listeJSP.jsp Normal file
View File

@ -0,0 +1,48 @@
<%@include file = "jspf/enteteJSPF.jspf" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@page import="java.util.ArrayList" %>
<h2>Liste des clients</h2><!-- comment -->
<!-- <p>Page en cours de construction</p>
<img src="images/pageEnConstruction.jpg" alt="Page en construction"/>-->
<table border="1" cellspacing="3" cellpadding="1">
<thead>
<tr>
<th>No</th>
<th>Civilité</th>
<th>Nom</th>
<th>Prénom</th>
<th>Mot de passe</th>
<th>No</th>
<th>Rue</th>
<th>Ville</th>
<th>Code postal</th>
<th>Mail</th>
<th>Tél</th>
<th>Date naissance</th>
</tr>
</thead>
<tbody>
<c:forEach items="${lesClients}" var="unClient">
<tr>
<td><c:out value="${unClient.getId()}"/></td>
<td><c:out value="${unClient.getCivilite()}"/></td>
<td><c:out value="${unClient.getNom()}"/></td>
<td><c:out value="${unClient.getPrenom()}"/></td>
<td><c:out value="${unClient.getMdp()}"/></td>
<td><c:out value="${unClient.getAdrNo()}"/></td>
<td><c:out value="${unClient.getAdrRue()}"/></td>
<td><c:out value="${unClient.getAdrVille()}"/></td>
<td><c:out value="${unClient.getAdrCP()}"/></td>
<td><c:out value="${unClient.getAdrmail()}"/></td>
<td><c:out value="${unClient.getTel()}"/></td>
<td><c:out value="${unClient.getDateNais()}"/></td>
</tr>
</c:forEach>
</tbody>
</table>
<br />
<%@include file="jspf/menuJSPF.jspf" %>
</body>
</html>

View File

@ -0,0 +1,58 @@
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@include file = "jspf/enteteJSPF.jspf" %>
<h2>Création d'un nouveau client</h2><!-- comment -->
<!-- <p>Page en cours de construction</p><!-- comment -->
<img src="images/pageEnConstruction.jpg" alt="Page en construction"/>
<fieldset>
<legend>Fiche client</legend>
<form name="fClient" action="NouveauClient" method="POST">
<label for="cbCivilite1">Mr </label>
<input type="radio" name="btrCivilite" id="btrCivilite1" value="Mr" checked />
<label for="cbCivilite2">Mme </label>
<input type="radio" name="btrCivilite" id="btrCivilite2" value="Mme" />
<label for="ztPrenom">Prénom </label>
<input type="text" name="ztPrenom" id="ztPrenom" value="" />
<label for="ztNom">Nom </label>
<input type="text" name="ztNom" id="ztNom" value="" />
<label for="ztPwd">Mot de passe </label>
<input type="password" name="ztPwd" id="ztPwd" value="" /><br>
Adresse postale :
<input type="text" name="ztNoRue" value="" placeholder="No"/>
<input type="text" name="ztRue" value="" placeholder="Rue"/>
<input type="text" name="ztCP" value="" placeholder="Code postal"/>
<input type="text" name="ztVille" value="" placeholder="Ville"/><br>
<label for="ztMail">Adresse mail </label>
<input type="email" name="ztMail" id="ztMail" value="" />
<label for="ztTel">Téléphone </label>
<input type="text" name="ztTel" id="ztTel" value="" />
<label for="ztDateNais">Date de naissance </label>
<input type="date" min="1921-01-01" name="ztDateNais" id="ztDateNais" value="" />
<br>
<input type="submit" value="Valider" />
</form>
</fieldset>
<br>
<p>
<c:choose>
<c:when test="${idClient >= 0}">
Le client no ${idClient} a été créé avec succès
</c:when>
<c:when test="${idClient == -1}">
E R R E U R : ${message}
</c:when>
<c:otherwise>
Cliquez sur <em>"Valider"</em> après avoir renseigné les informations demandées
</c:otherwise>
</c:choose>
</p>
<%@include file="jspf/menuJSPF.jspf" %>
<article>
<h3>Liste des numéros des clients récement créés : </h3>
<c:forEach items="${sessionScope.lesNvxClients}" var="unClient">
${unClient} -
</c:forEach>
</article>
</body>
</html>

35
web/WEB-INF/web.xml Normal file
View File

@ -0,0 +1,35 @@
<?xml version="1.0" encoding="UTF-8"?>
<web-app version="3.1" xmlns="http://xmlns.jcp.org/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-app_3_1.xsd">
<filter>
<filter-name>AuthentifFiltrer</filter-name>
<filter-class>com.test.filter.AuthentifFiltrer</filter-class>
</filter>
<filter-mapping>
<filter-name>AuthentifFiltrer</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
<servlet>
<servlet-name>AccueilServlet</servlet-name>
<servlet-class>com.test.servlets.AccueilServlet</servlet-class>
</servlet>
<servlet>
<servlet-name>NouveauServlet</servlet-name>
<servlet-class>com.test.servlets.NouveauServlet</servlet-class>
</servlet>
<servlet>
<servlet-name>AuthentificationServlet</servlet-name>
<servlet-class>com.test.servlets.AuthentificationServlet</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>AccueilServlet</servlet-name>
<url-pattern>/Accueil</url-pattern>
</servlet-mapping>
<servlet-mapping>
<servlet-name>NouveauServlet</servlet-name>
<url-pattern>/NouveauClient</url-pattern>
</servlet-mapping>
<servlet-mapping>
<servlet-name>AuthentificationServlet</servlet-name>
<url-pattern>/Authentification</url-pattern>
</servlet-mapping>
</web-app>

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.0 KiB

16
web/index.html Normal file
View File

@ -0,0 +1,16 @@
<!DOCTYPE html>
<!--
To change this license header, choose License Headers in Project Properties.
To change this template file, choose Tools | Templates
and open the template in the editor.
-->
<html>
<head>
<title>Gestion des clients</title>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
</head>
<body>
<div>TODO write content</div>
</body>
</html>

41
web/welcomeJSF.jsp Normal file
View File

@ -0,0 +1,41 @@
<%--
Licensed to the Apache Software Foundation (ASF) under one
or more contributor license agreements. See the NOTICE file
distributed with this work for additional information
regarding copyright ownership. The ASF licenses this file
to you under the Apache License, Version 2.0 (the
"License"); you may not use this file except in compliance
with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing,
software distributed under the License is distributed on an
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
KIND, either express or implied. See the License for the
specific language governing permissions and limitations
under the License.
--%>
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<%@taglib prefix="f" uri="http://java.sun.com/jsf/core"%>
<%@taglib prefix="h" uri="http://java.sun.com/jsf/html"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<%--
This file is an entry point for JavaServer Faces application.
--%>
<f:view>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
<title>JSP Page</title>
</head>
<body>
<h1><h:outputText value="JavaServer Faces"/></h1>
</body>
</html>
</f:view>