Compare commits

...

No commits in common. "master" and "main" have entirely different histories.
master ... main

25 changed files with 3 additions and 2484 deletions

3
README.md Normal file
View File

@ -0,0 +1,3 @@
# Test2JakartaV7
Début persistance des données

View File

@ -1,71 +0,0 @@
<?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="Test2JakartaV7-2" default="default" basedir=".">
<description>Builds, tests, and runs the project Test2JakartaV7-2.</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>

View File

@ -1,69 +0,0 @@
<?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>
<pathelement path="${tomcat.home}/lib/catalina-ant.jar"/>
<pathelement path="${tomcat.home}/lib/tomcat-coyote.jar"/>
<pathelement path="${tomcat.home}/lib/tomcat-util.jar"/>
<pathelement path="${tomcat.home}/bin/tomcat-juli.jar"/>
</classpath>
</taskdef>
<deploy url="${tomcat.url}/manager/text" 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>
<pathelement path="${tomcat.home}/lib/catalina-ant.jar"/>
<pathelement path="${tomcat.home}/lib/tomcat-coyote.jar"/>
<pathelement path="${tomcat.home}/lib/tomcat-util.jar"/>
<pathelement path="${tomcat.home}/bin/tomcat-juli.jar"/>
</classpath>
</taskdef>
<undeploy url="${tomcat.url}/manager/text" username="${tomcat.username}"
password="${tomcat.password}" path="${Context(path)}"/>
</target>
</project>

File diff suppressed because it is too large Load Diff

View File

@ -1,8 +0,0 @@
build.xml.data.CRC32=ff2a0cb9
build.xml.script.CRC32=dffdee25
build.xml.stylesheet.CRC32=1707db4f@1.98.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=ff2a0cb9
nbproject/build-impl.xml.script.CRC32=f38222bd
nbproject/build-impl.xml.stylesheet.CRC32=334708a0@1.98.0.1

View File

@ -1,90 +0,0 @@
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
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=
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=
excludes=
file.reference.jakarta.servlet.jsp.jstl-2.0.0.jar=../../../../Users/sio/Downloads/jakarta.servlet.jsp.jstl-2.0.0.jar
file.reference.jakarta.servlet.jsp.jstl-api-2.0.0.jar=../../../../Users/sio/Downloads/jakarta.servlet.jsp.jstl-api-2.0.0.jar
file.reference.mysql-connector-java-8.0.23.jar=C:\\Users\\sio\\Downloads\\mysql-connector-java-8.0.23.jar
file.reference.mysql-connector-java-8.0.23.jar-1=C:\\Program Files\\Apache Software Foundation\\Tomcat 10.1\\drivers\\mysql-connector-java-8.0.23.jar
includes=**
j2ee.compile.on.save=true
j2ee.copy.static.files.on.save=true
j2ee.deploy.on.save=true
j2ee.platform=10-web
j2ee.platform.classpath=${j2ee.server.home}/bin/tomcat-juli.jar:${j2ee.server.home}/lib/annotations-api.jar:${j2ee.server.home}/lib/catalina-ant.jar:${j2ee.server.home}/lib/catalina-ha.jar:${j2ee.server.home}/lib/catalina-ssi.jar:${j2ee.server.home}/lib/catalina-storeconfig.jar:${j2ee.server.home}/lib/catalina-tribes.jar:${j2ee.server.home}/lib/catalina.jar:${j2ee.server.home}/lib/ecj-4.27.jar:${j2ee.server.home}/lib/el-api.jar:${j2ee.server.home}/lib/jakartaee-migration-1.0.8-shaded.jar:${j2ee.server.home}/lib/jasper-el.jar:${j2ee.server.home}/lib/jasper.jar:${j2ee.server.home}/lib/jaspic-api.jar:${j2ee.server.home}/lib/jsp-api.jar:${j2ee.server.home}/lib/mysql-connector-java-8.0.23.jar:${j2ee.server.home}/lib/servlet-api.jar:${j2ee.server.home}/lib/tomcat-api.jar:${j2ee.server.home}/lib/tomcat-coyote-ffm.jar:${j2ee.server.home}/lib/tomcat-coyote.jar:${j2ee.server.home}/lib/tomcat-dbcp.jar:${j2ee.server.home}/lib/tomcat-i18n-cs.jar:${j2ee.server.home}/lib/tomcat-i18n-de.jar:${j2ee.server.home}/lib/tomcat-i18n-es.jar:${j2ee.server.home}/lib/tomcat-i18n-fr.jar:${j2ee.server.home}/lib/tomcat-i18n-ja.jar:${j2ee.server.home}/lib/tomcat-i18n-ko.jar:${j2ee.server.home}/lib/tomcat-i18n-pt-BR.jar:${j2ee.server.home}/lib/tomcat-i18n-ru.jar:${j2ee.server.home}/lib/tomcat-i18n-zh-CN.jar:${j2ee.server.home}/lib/tomcat-jdbc.jar:${j2ee.server.home}/lib/tomcat-jni.jar:${j2ee.server.home}/lib/tomcat-util-scan.jar:${j2ee.server.home}/lib/tomcat-util.jar:${j2ee.server.home}/lib/tomcat-websocket.jar:${j2ee.server.home}/lib/websocket-api.jar:${j2ee.server.home}/lib/websocket-client-api.jar
j2ee.server.type=Tomcat
jar.compress=false
javac.classpath=\
${file.reference.jakarta.servlet.jsp.jstl-2.0.0.jar}:\
${file.reference.jakarta.servlet.jsp.jstl-api-2.0.0.jar}:\
${file.reference.mysql-connector-java-8.0.23.jar}:\
${file.reference.mysql-connector-java-8.0.23.jar-1}
# Space-separated list of extra javac options
javac.compilerargs=
javac.debug=true
javac.deprecation=false
javac.processorpath=\
${javac.classpath}
javac.source=21
javac.target=21
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=Test2JakartaV7-2.war
web.docbase.dir=web
webinf.dir=web/WEB-INF

View File

@ -1,35 +0,0 @@
<?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>Test2JakartaV7-2</name>
<minimum-ant-version>1.6.5</minimum-ant-version>
<web-module-libraries>
<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>
<library dirs="200">
<file>${file.reference.mysql-connector-java-8.0.23.jar}</file>
<path-in-war>WEB-INF/lib</path-in-war>
</library>
<library dirs="200">
<file>${file.reference.mysql-connector-java-8.0.23.jar-1}</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>

View File

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

View File

@ -1,56 +0,0 @@
/*
* 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 bdd;
import java.sql.Statement;
import javabeans.Client;
import java.util.ArrayList;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
/**
*
* @author sio
*/
public class ClientMySQL {
private final Connection theConnection = Connexion.getConnect("10.121.38.165", "bdclient", "adminBDClient", "mdpBDClient");
public void create(Client leClient){
}
public Client read(int num){
return null;
}
public void update(int num){
}
public void delete(int num){
}
public ArrayList<String> readAll(){
ArrayList <String> lesClients = new ArrayList<>();
try{
Statement stmt = theConnection.createStatement();
ResultSet resultQ = null;
resultQ = stmt.executeQuery("SELECT * FROM client");
while(resultQ.next()){
String resultat = resultQ.getString("nom") + " " + resultQ.getString("prénom");
lesClients.add(resultat);
}
resultQ.close();
stmt.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;
}
}

View File

@ -1,61 +0,0 @@
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

@ -1,86 +0,0 @@
/*
* 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 gestionClient;
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;
/**
*
* @author famille Thevenot
*/
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);
getServletContext().getRequestDispatcher("/WEB-INF/accueilVue.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

@ -1,95 +0,0 @@
/*
* 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 gestionClient;
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 testForms.AuthentifForm;
/**
*
* @author famille Thevenot
*/
public class AuthentifServlet 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 AuthentifServlet</title>");
out.println("</head>");
out.println("<body>");
out.println("<h1>Servlet AuthentifServlet 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);
}
/**
* 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);
//Création de l'objet leControl 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("controlForm", leControle);
request.setAttribute("isAdmin", isAdmin);
//Affichage JSP
getServletContext().getRequestDispatcher("/WEB-INF/accueilVue.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

@ -1,93 +0,0 @@
/*
* 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 gestionClient;
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 famille Thevenot
*/
@WebServlet(name = "ListeServlet2", urlPatterns = {"/ListeClients"})
public class ListeServlet2 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 ListeServlet2</title>");
out.println("</head>");
out.println("<body>");
out.println("<h1>Servlet ListeServlet2 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 {
System.out.println("ListeServlet2");
ClientMySQL cli = new ClientMySQL();
// parcourir la arraylist
//System.out.println(cli.readAll());
request.setAttribute("laListe", cli.readAll());
getServletContext().getRequestDispatcher("/WEB-INF/listeClientsVue.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

@ -1,85 +0,0 @@
/*
* 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 gestionClient;
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;
/**
*
* @author famille Thevenot
*/
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 {
getServletContext().getRequestDispatcher("/WEB-INF/nouveauClientVue.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

@ -1,42 +0,0 @@
/*
* 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 javabeans;
/**
*
* @author sio
*/
public class Client {
//variables membres
private int id;
private String nom;
private 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;
}
public String getMail() {
return mail;
}
public void setMail(String mail) {
this.mail = mail;
}
}

View File

@ -1,66 +0,0 @@
/*
* 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 javabeans;
import java.util.Objects;
/**
*
* @author famille Thevenot
*/
public class User {
private String pseudo;
private String motDePasse;
public User(String pseudo, String motDePasse) {
this.pseudo = pseudo;
this.motDePasse = motDePasse;
}
public User(String header) {
throw new UnsupportedOperationException("Not supported yet."); // Generated from nbfs://nbhost/SystemFileSystem/Templates/Classes/Code/GeneratedMethodBody
}
public String getPseudo() {
return pseudo;
}
public void setPseudo(String pseudo) {
this.pseudo = pseudo;
}
public String getMotDePasse() {
return motDePasse;
}
public void setMotDePasse(String motDePasse) {
this.motDePasse = motDePasse;
}
@Override
public int hashCode() {
int hash = 5;
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;
}
return Objects.equals(this.motDePasse, other.motDePasse);
}
}

View File

@ -1,38 +0,0 @@
/*
* 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 testForms;
import jakarta.servlet.http.HttpServletRequest;
import javabeans.User;
/**
*
* @author famille Thevenot
*/
public class AuthentifForm {
private String resultat;
public String getResultat() {
return resultat;
}
public void setResultat(String resultat) {
this.resultat = resultat;
}
public boolean controlerAdmin(HttpServletRequest request)
{
User admin = new User("admin", "minda");
User userSaisi = new User(request.getParameter("ztPseudo"),request.getParameter("ztMDP"));
//test du compte admin
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

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

View File

@ -1,43 +0,0 @@
<%--
Document : accueilJSPV6
Created on : 9 sept. 2024, 12:32:01
Author : famille Thevenot
--%>
<%@page import="testForms.AuthentifForm"%>
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Accueil des clients</title>
</head>
<%@include file="jspf/enteteClient.jspf" %>
<%@include file="jspf/menuClient.jspf" %>
<p>Bienvenue sur la nouvelle application de gestion des clients écrite avec JakartaEE</p>
<!-- utilisation EL -->
<c:out value="${controlForm.getResultat()}" default="Je ne sais pas encore si vous êtes administrateur, authentifiez-vous !" />
<c:choose>
<c:when test="${param.ztPseudo != null}" >
<p>Bonjour ${param.ztPseudo }</p>
</c:when>
<c:otherwise>
<!-- Affichage formulaire si pas de pseudo -->
<form action="authentification" method="post">
<label for="fpseudo">Pseudo :</label>
<input type="text" id="fpseudo" name="ztPseudo" required="required"><br><br>
<label for="fpwd">Mot de passe :</label>
<input type="password" id="fpwd" name="ztMDP" required="required"><br><br>
<input type="submit" value="Submit">
</form>
</c:otherwise>
</c:choose>
</html>

View File

@ -1,3 +0,0 @@
<%-- any content can be specified here e.g.: --%>
<%@ page pageEncoding="UTF-8" %>
<h1>Gestion des clients</h1>

View File

@ -1,10 +0,0 @@
<%-- any content can be specified here e.g.: --%>
<%@ page pageEncoding="UTF-8" %>
<nav>
<ul>
<li><a href='./'>Accueil</a></li>
<li><a href='listeClients'>Liste des clients</a></li>
<li><a href='nouveauClient'>Nouveau clients</a></li>
</ul>
</nav>

View File

@ -1,23 +0,0 @@
<%--
Document : listeClientsVue
Created on : 15 sept. 2024, 18:51:03
Author : famille Thevenot
--%>
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Liste des clients</title>
</head>
<body>
<%@include file="jspf/enteteClient.jspf" %>
<%@include file="jspf/menuClient.jspf" %>
<h2>Liste des clients</h2>
<p>Page en construction2</p>
<c:out value="${laListe}" default="La liste doit être là" />
<c:out value="${laListe}"/>
</body>
</html>

View File

@ -1,20 +0,0 @@
<%--
Document : nouveauClientVue
Created on : 15 sept. 2024, 18:49:28
Author : famille Thevenot
--%>
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Nouveau client</title>
</head>
<body>
<%@include file="jspf/enteteClient.jspf" %>
<%@include file="jspf/menuClient.jspf" %>
<h2>Nouveau client</h2>
<p>Page en construction</p>
</body>
</html>

View File

@ -1,35 +0,0 @@
<?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">
<servlet>
<servlet-name>ListeServlet</servlet-name>
<servlet-class>ListeServlet2</servlet-class>
</servlet>
<servlet>
<servlet-name>AccueilServlet</servlet-name>
<servlet-class>gestionClient.AccueilServlet</servlet-class>
</servlet>
<servlet>
<servlet-name>NouveauServlet</servlet-name>
<servlet-class>gestionClient.NouveauServlet</servlet-class>
</servlet>
<servlet>
<servlet-name>AuthentifServlet</servlet-name>
<servlet-class>gestionClient.AuthentifServlet</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>ListeServlet2</servlet-name>
<url-pattern>/listeClients</url-pattern>
</servlet-mapping>
<servlet-mapping>
<servlet-name>AccueilServlet</servlet-name>
<url-pattern>/</url-pattern>
</servlet-mapping>
<servlet-mapping>
<servlet-name>NouveauServlet</servlet-name>
<url-pattern>/nouveauClient</url-pattern>
</servlet-mapping>
<servlet-mapping>
<servlet-name>AuthentifServlet</servlet-name>
<url-pattern>/authentification</url-pattern>
</servlet-mapping>
</web-app>

View File

@ -1,15 +0,0 @@
<!DOCTYPE html>
<!--
Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license
Click nbfs://nbhost/SystemFileSystem/Templates/JSP_Servlet/Html.html to edit this template
-->
<html>
<head>
<title>TODO supply a title</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>