Liste client +
Connexion Bdd + Ajout d'un client
This commit is contained in:
110
src/main/java/com/test/bdd/ClientMysql.java
Normal file
110
src/main/java/com/test/bdd/ClientMysql.java
Normal file
@@ -0,0 +1,110 @@
|
||||
/*
|
||||
* Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license
|
||||
* Click nbfs://nbhost/SystemFileSystem/Templates/Classes/Class.java to edit this template
|
||||
*/
|
||||
package com.test.bdd;
|
||||
|
||||
import java.sql.Connection;
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
import java.sql.Statement;
|
||||
import java.util.ArrayList;
|
||||
import com.test.beans.Client;
|
||||
import java.sql.PreparedStatement;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author emile.malcuit
|
||||
*/
|
||||
public class ClientMysql {
|
||||
private Connection laConnexion = connexionSQL.getConnect("192.168.100.100", "bdclient", "adminClient", "admin");
|
||||
|
||||
public ClientMysql() {
|
||||
}
|
||||
|
||||
public Connection getLaConnexion() {
|
||||
return laConnexion;
|
||||
}
|
||||
|
||||
|
||||
|
||||
public void createClient(Client newCli) {
|
||||
String commande = "INSERT INTO client(nom, prenom, mail) VALUES (?, ?, ?)";
|
||||
|
||||
try (PreparedStatement pstmt = laConnexion.prepareStatement(commande)) {
|
||||
pstmt.setString(1, newCli.getNom());
|
||||
pstmt.setString(2, newCli.getPrenom());
|
||||
pstmt.setString(3, newCli.getMail());
|
||||
|
||||
int rowsInserted = pstmt.executeUpdate();
|
||||
|
||||
if (rowsInserted > 0) {
|
||||
System.out.println("Client inséré avec succès !");
|
||||
}
|
||||
} catch (SQLException ex) {
|
||||
System.err.println("Erreur lors de l'insertion du client : " + ex.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
public ArrayList<Client> readAll(){
|
||||
ArrayList<Client> lesClients=new ArrayList<>();
|
||||
try {
|
||||
Statement stmt=laConnexion.createStatement();
|
||||
ResultSet resultQ=null;
|
||||
resultQ=stmt.executeQuery("SELECT * FROM client;");
|
||||
while (resultQ.next()){
|
||||
Client resultat=new Client(resultQ.getInt("id"),resultQ.getString("nom"),resultQ.getString("prenom"),resultQ.getString("mail"));
|
||||
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;
|
||||
}
|
||||
|
||||
|
||||
public Client read(int id){
|
||||
String commande = "SELECT * FROM client WHERE id = ?";
|
||||
Client recherche = new Client();
|
||||
|
||||
try(PreparedStatement pstmt = laConnexion.prepareStatement(commande)){
|
||||
pstmt.setString(1, Integer.toString(id));
|
||||
ResultSet resultQ = pstmt.executeQuery();
|
||||
recherche.setId(resultQ.getInt("id"));
|
||||
recherche.setNom(resultQ.getString("nom"));
|
||||
recherche.setPrenom(resultQ.getString("prenom"));
|
||||
recherche.setMail(resultQ.getString("mail"));
|
||||
|
||||
} catch (SQLException ex) {
|
||||
System.err.println("Erreur lors de la recherche du client : " + ex.getMessage());
|
||||
}
|
||||
|
||||
return recherche;
|
||||
}
|
||||
|
||||
|
||||
public void delete(int id){
|
||||
String commande = "DELETE FROM client WHERE id = ?";
|
||||
|
||||
try(PreparedStatement pstmt = laConnexion.prepareStatement(commande)){
|
||||
pstmt.setString(1, Integer.toString(id));
|
||||
ResultSet resultQ = pstmt.executeQuery();
|
||||
|
||||
}catch(SQLException ex){
|
||||
System.err.println("Erreur lors de la suppression du client : " + ex.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
61
src/main/java/com/test/bdd/connexionSQL.java
Normal file
61
src/main/java/com/test/bdd/connexionSQL.java
Normal file
@@ -0,0 +1,61 @@
|
||||
package com.test.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 connexionSQL {
|
||||
private static Connection connect; // Variable de connexion
|
||||
|
||||
/**
|
||||
* Constructeur d'une connexion avec une base de données
|
||||
* @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 connexionSQL(String serveur, String bdd, String nomUtil, String mdp) {
|
||||
try {
|
||||
// 1. Chargement du driver
|
||||
//Class.forName("com.mysql.jdbc.Driver");
|
||||
Class.forName("org.mariadb.jdbc.Driver");
|
||||
System.out.println("Driver MariaDb Ok");
|
||||
|
||||
// 2. Initialisation des paramètres de connexion
|
||||
String host = serveur; // Serveur de bd
|
||||
String dbname = bdd; // Nom bd
|
||||
String url = "jdbc:mariadb://" + host + "/" + dbname; // url de connexion
|
||||
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 <20>tablie (Cr<43>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<6E>es
|
||||
* @param nomUtil nom utilisateur
|
||||
* @param mdp mot de passe li<6C> <20> l'utilisateur
|
||||
* @return connection <20>tablie
|
||||
*/
|
||||
public static Connection getConnect(String serveur, String bdd, String nomUtil, String mdp) {
|
||||
if (connect == null) {
|
||||
new connexionSQL(serveur, bdd, nomUtil, mdp);
|
||||
}
|
||||
System.out.println("Connexion validé");
|
||||
return connect;
|
||||
}
|
||||
}
|
||||
72
src/main/java/com/test/beans/Client.java
Normal file
72
src/main/java/com/test/beans/Client.java
Normal file
@@ -0,0 +1,72 @@
|
||||
/*
|
||||
* Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license
|
||||
* Click nbfs://nbhost/SystemFileSystem/Templates/Classes/Class.java to edit this template
|
||||
*/
|
||||
package com.test.beans;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author emile.malcuit
|
||||
*/
|
||||
public class Client {
|
||||
private int id;
|
||||
private String nom;
|
||||
private String prenom;
|
||||
private String mail;
|
||||
|
||||
|
||||
public Client() {
|
||||
}
|
||||
|
||||
public Client(int id, String nom, String prenom, String mail) {
|
||||
this.id = id;
|
||||
this.nom = nom;
|
||||
this.prenom = prenom;
|
||||
this.mail = mail;
|
||||
}
|
||||
|
||||
|
||||
|
||||
public int getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(int id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public String getNom() {
|
||||
return nom;
|
||||
}
|
||||
|
||||
public void setNom(String nom) {
|
||||
this.nom = nom;
|
||||
}
|
||||
|
||||
public String getPrenom() {
|
||||
return prenom;
|
||||
}
|
||||
|
||||
public void setPrenom(String prenom) {
|
||||
this.prenom = prenom;
|
||||
}
|
||||
|
||||
public String getMail() {
|
||||
return mail;
|
||||
}
|
||||
|
||||
public void setMail(String mail) {
|
||||
this.mail = mail;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "Client{" + "id=" + id + ", nom=" + nom + ", prenom=" + prenom + ", mail=" + mail + '}';
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
62
src/main/java/com/test/beans/User.java
Normal file
62
src/main/java/com/test/beans/User.java
Normal file
@@ -0,0 +1,62 @@
|
||||
/*
|
||||
* Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license
|
||||
* Click nbfs://nbhost/SystemFileSystem/Templates/Classes/Class.java to edit this template
|
||||
*/
|
||||
package com.test.beans;
|
||||
|
||||
import java.util.Objects;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author emile.malcuit
|
||||
*/
|
||||
public class User {
|
||||
private String pseudo;
|
||||
private String motDePasse;
|
||||
|
||||
|
||||
|
||||
public User(String pseudo, String motDePasse) {
|
||||
this.pseudo = pseudo;
|
||||
this.motDePasse = motDePasse;
|
||||
}
|
||||
|
||||
|
||||
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 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);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
45
src/main/java/com/test/forms/AuthentifForm.java
Normal file
45
src/main/java/com/test/forms/AuthentifForm.java
Normal file
@@ -0,0 +1,45 @@
|
||||
/*
|
||||
* Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license
|
||||
* Click nbfs://nbhost/SystemFileSystem/Templates/Classes/Class.java to edit this template
|
||||
*/
|
||||
package com.test.forms;
|
||||
|
||||
import com.test.beans.User;
|
||||
import jakarta.servlet.http.HttpServletRequest;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author emile.malcuit
|
||||
*/
|
||||
public class AuthentifForm {
|
||||
private String resultat = "Vous n'êtes pas administrateur";
|
||||
|
||||
public String getResultat() {
|
||||
return resultat;
|
||||
}
|
||||
|
||||
public void setResultat(String resultat) {
|
||||
this.resultat = resultat;
|
||||
}
|
||||
|
||||
|
||||
public boolean controlerAdmin(HttpServletRequest request){
|
||||
User admin = new User("Lovelace", "Ada");
|
||||
String login = request.getParameter("user_name");
|
||||
String mdp = request.getParameter("user_password");
|
||||
User userSaisi = new User(login, mdp);
|
||||
boolean retour = false;
|
||||
if(userSaisi.equals(admin)){
|
||||
retour = true;
|
||||
setResultat("Vous êtes administrateur");
|
||||
}
|
||||
return retour;
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
98
src/main/java/com/test/servlets/AuthentifServlet.java
Normal file
98
src/main/java/com/test/servlets/AuthentifServlet.java
Normal file
@@ -0,0 +1,98 @@
|
||||
/*
|
||||
* Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license
|
||||
* Click nbfs://nbhost/SystemFileSystem/Templates/JSP_Servlet/Servlet.java to edit this template
|
||||
*/
|
||||
package com.test.servlets;
|
||||
|
||||
import com.test.forms.AuthentifForm;
|
||||
import java.io.IOException;
|
||||
import java.io.PrintWriter;
|
||||
import jakarta.servlet.ServletException;
|
||||
import jakarta.servlet.annotation.WebServlet;
|
||||
import jakarta.servlet.http.HttpServlet;
|
||||
import jakarta.servlet.http.HttpServletRequest;
|
||||
import jakarta.servlet.http.HttpServletResponse;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author emile.malcuit
|
||||
*/
|
||||
@WebServlet(name="AuthentifServlet", urlPatterns={"/Authentification"})
|
||||
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);
|
||||
|
||||
AuthentifForm authent = new AuthentifForm();
|
||||
boolean isAdmin = authent.controlerAdmin(request);
|
||||
String status = authent.getResultat();
|
||||
|
||||
request.setAttribute("isAdmin", isAdmin);
|
||||
request.setAttribute("status", status);
|
||||
request.setAttribute("pseudo", request.getAttribute("user_name"));
|
||||
|
||||
getServletContext().getRequestDispatcher("/WEB-INF/AcceuilJSP.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>
|
||||
|
||||
}
|
||||
@@ -4,6 +4,8 @@
|
||||
*/
|
||||
package com.test.servlets;
|
||||
|
||||
import com.test.bdd.ClientMysql;
|
||||
import com.test.beans.Client;
|
||||
import java.io.IOException;
|
||||
import java.io.PrintWriter;
|
||||
import jakarta.servlet.ServletException;
|
||||
@@ -11,6 +13,7 @@ import jakarta.servlet.annotation.WebServlet;
|
||||
import jakarta.servlet.http.HttpServlet;
|
||||
import jakarta.servlet.http.HttpServletRequest;
|
||||
import jakarta.servlet.http.HttpServletResponse;
|
||||
import java.util.ArrayList;
|
||||
|
||||
/**
|
||||
*
|
||||
@@ -58,6 +61,10 @@ public class ListeServlet extends HttpServlet {
|
||||
protected void doGet(HttpServletRequest request, HttpServletResponse response)
|
||||
throws ServletException, IOException {
|
||||
//processRequest(request, response);
|
||||
ClientMysql UnClient = new ClientMysql();
|
||||
ArrayList<Client> lesClients = UnClient.readAll();
|
||||
|
||||
request.setAttribute("lesClients", lesClients);
|
||||
getServletContext().getRequestDispatcher("/WEB-INF/ListeClientsJSP.jsp").forward(request, response);
|
||||
}
|
||||
|
||||
|
||||
@@ -4,6 +4,8 @@
|
||||
*/
|
||||
package com.test.servlets;
|
||||
|
||||
import com.test.bdd.ClientMysql;
|
||||
import com.test.beans.Client;
|
||||
import java.io.IOException;
|
||||
import java.io.PrintWriter;
|
||||
import jakarta.servlet.ServletException;
|
||||
@@ -73,7 +75,19 @@ public class NouveauServlet extends HttpServlet {
|
||||
@Override
|
||||
protected void doPost(HttpServletRequest request, HttpServletResponse response)
|
||||
throws ServletException, IOException {
|
||||
processRequest(request, response);
|
||||
|
||||
//Recuperation des informations inserer dans le formulaire nouveau client
|
||||
Client newCli = new Client();
|
||||
newCli.setNom(request.getParameter("nom"));
|
||||
newCli.setPrenom(request.getParameter("prenom"));
|
||||
newCli.setMail(request.getParameter("email"));
|
||||
|
||||
//Insertion du client en db
|
||||
ClientMysql cliSQL = new ClientMysql();
|
||||
cliSQL.createClient(newCli);
|
||||
|
||||
response.sendRedirect(request.getContextPath() + "/ListeClients");
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
95
src/main/java/com/test/servlets/TestClientSQL.java
Normal file
95
src/main/java/com/test/servlets/TestClientSQL.java
Normal file
@@ -0,0 +1,95 @@
|
||||
package com.test.servlets;
|
||||
|
||||
/*
|
||||
* 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
|
||||
*/
|
||||
|
||||
import com.test.bdd.ClientMysql;
|
||||
import com.test.beans.Client;
|
||||
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 java.util.ArrayList;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author emile.malcuit
|
||||
*/
|
||||
public class TestClientSQL 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 TestClientSQL</title>");
|
||||
out.println("</head>");
|
||||
out.println("<body>");
|
||||
ClientMysql UnClient = new ClientMysql();
|
||||
ArrayList<Client> lesClients = UnClient.readAll();
|
||||
for(Client unClient:lesClients){
|
||||
out.println(unClient.toString());
|
||||
}
|
||||
out.println("<h1>Servlet TestClientSQL 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);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a short description of the servlet.
|
||||
*
|
||||
* @return a String containing servlet description
|
||||
*/
|
||||
@Override
|
||||
public String getServletInfo() {
|
||||
return "Short description";
|
||||
}// </editor-fold>
|
||||
|
||||
}
|
||||
@@ -14,32 +14,28 @@
|
||||
|
||||
</head>
|
||||
<%@include file="jspf/entete.jspf" %>
|
||||
<body>
|
||||
|
||||
<body>
|
||||
<%
|
||||
Boolean isAdmin = (Boolean) request.getAttribute("isAdmin");
|
||||
String status = (String) request.getAttribute("status");
|
||||
String login = (String) request.getAttribute("pseudo");
|
||||
|
||||
|
||||
<!--<a href="http://localhost:8080/Test2Jakarta/NouveauClient">
|
||||
Ajout d'un nouveau client</a>
|
||||
</br>
|
||||
<a href="http://localhost:8080/Test2Jakarta/ListeClients">
|
||||
La liste des Clients</a>-->
|
||||
<%
|
||||
|
||||
Object connect = request.getAttribute("connect");
|
||||
Object login = request.getAttribute("login");
|
||||
if(connect.equals("true")){
|
||||
|
||||
%>
|
||||
if (isAdmin != null && isAdmin) {
|
||||
%>
|
||||
<%@include file="jspf/menu.jspf" %>
|
||||
<p>Test ${connect}</p>
|
||||
<p>Test ${isAdmin}</p>
|
||||
<h1>Hello mon ami ${login}</h1>
|
||||
<p>Bienvenue sur la nouvelle application de gestion des clients
|
||||
écrite avec JakartaEE</p>
|
||||
<%
|
||||
}else{
|
||||
%>
|
||||
|
||||
<form action="${pageContext.request.contextPath}/Acceuil" method="post">
|
||||
<p>${status}</p>
|
||||
<%
|
||||
} else if (isAdmin != null && !isAdmin) {
|
||||
%>
|
||||
<h2>Hello ${login}</h2>
|
||||
<p>${status}</p>
|
||||
<%
|
||||
} else {
|
||||
%>
|
||||
<form action="${pageContext.request.contextPath}/Authentification" method="post">
|
||||
<div class="form-glob">
|
||||
<h2>Formulaire de connexion</h2>
|
||||
<div class="connexion">
|
||||
@@ -61,9 +57,9 @@
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
<%
|
||||
<%
|
||||
}
|
||||
%>
|
||||
%>
|
||||
|
||||
</body>
|
||||
</body>
|
||||
</html>
|
||||
|
||||
@@ -5,6 +5,7 @@
|
||||
--%>
|
||||
|
||||
<%@page contentType="text/html" pageEncoding="UTF-8"%>
|
||||
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
@@ -13,11 +14,31 @@
|
||||
<link href="style/style.css" rel="stylesheet">
|
||||
</head>
|
||||
<body>
|
||||
<%
|
||||
%>
|
||||
<%@include file="jspf/entete.jspf" %>
|
||||
<%@include file="jspf/menu.jspf" %>
|
||||
|
||||
<h1>Hello World!</h1>
|
||||
<p>Liste des clients
|
||||
<p>Liste des clients</p>
|
||||
</br>
|
||||
Page en construction</p>
|
||||
|
||||
<table>
|
||||
<tr>
|
||||
<th>ID</th>
|
||||
<th>Nom</th>
|
||||
<th>Prénom</th>
|
||||
<th>Mail</th>
|
||||
</tr>
|
||||
<c:forEach var="client" items="${lesClients}">
|
||||
<tr>
|
||||
<td>${client.id}</td>
|
||||
<td>${client.nom}</td>
|
||||
<td>${client.prenom}</td>
|
||||
<td>${client.mail}</td>
|
||||
</tr>
|
||||
</c:forEach>
|
||||
</table>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
|
||||
@@ -16,8 +16,22 @@
|
||||
<%@include file="jspf/entete.jspf" %>
|
||||
<%@include file="jspf/menu.jspf" %>
|
||||
<h1>Bonjour Les Zouaves</h1>
|
||||
<p>Création d’un nouveau client
|
||||
<p>Création d’un nouveau client </p>
|
||||
</br>
|
||||
Page en construction</p>
|
||||
<h2>Insertion de client</h2>
|
||||
<form action="${pageContext.request.contextPath}/NouveauClient" method="POST">
|
||||
<label for="nom">Nom :</label><br />
|
||||
<input type="text" id="nom" name="nom" required /><br /><br />
|
||||
|
||||
<label for="prenom">Prénom :</label><br />
|
||||
<input type="text" id="prenom" name="prenom" required /><br /><br />
|
||||
|
||||
<label for="email">E-mail :</label><br />
|
||||
<input type="text" id="email" name="email" required /><br /><br />
|
||||
|
||||
<div class="valider">
|
||||
<input type="submit" value="Insérer" />
|
||||
</div>
|
||||
</form>
|
||||
</body>
|
||||
</html>
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
<%-- any content can be specified here e.g.: --%>
|
||||
<%@ page pageEncoding="UTF-8" %>
|
||||
<nav>
|
||||
<a href="http://localhost:8080/Test2Jakarta/Acceuil">Acceuil</a>
|
||||
<a href="http://localhost:8080/Test2Jakarta/ListeClients">Liste des Clients</a>
|
||||
<a href="http://localhost:8080/Test2Jakarta/NouveauClient">Nouveau Client</a>
|
||||
<a href="${pageContext.request.contextPath}/Acceuil">Acceuil</a>
|
||||
<a href="${pageContext.request.contextPath}/ListeClients">Liste des Clients</a>
|
||||
<a href="${pageContext.request.contextPath}/NouveauClient">Nouveau Client</a>
|
||||
</nav>
|
||||
|
||||
@@ -12,6 +12,14 @@
|
||||
<servlet-name>ListeServlet</servlet-name>
|
||||
<servlet-class>com.test.servlets.ListeServlet</servlet-class>
|
||||
</servlet>
|
||||
<servlet>
|
||||
<servlet-name>AuthentifServlet</servlet-name>
|
||||
<servlet-class>com.test.servlets.AuthentifServlet</servlet-class>
|
||||
</servlet>
|
||||
<servlet>
|
||||
<servlet-name>TestClientSQL</servlet-name>
|
||||
<servlet-class>com.test.servlets.TestClientSQL</servlet-class>
|
||||
</servlet>
|
||||
<servlet-mapping>
|
||||
<servlet-name>AcceuilServlet</servlet-name>
|
||||
<url-pattern>/Acceuil</url-pattern>
|
||||
@@ -24,6 +32,14 @@
|
||||
<servlet-name>ListeServlet</servlet-name>
|
||||
<url-pattern>/ListeClients</url-pattern>
|
||||
</servlet-mapping>
|
||||
<servlet-mapping>
|
||||
<servlet-name>AuthentifServlet</servlet-name>
|
||||
<url-pattern>/Authentification</url-pattern>
|
||||
</servlet-mapping>
|
||||
<servlet-mapping>
|
||||
<servlet-name>TestClientSQL</servlet-name>
|
||||
<url-pattern>/TestClientSQL</url-pattern>
|
||||
</servlet-mapping>
|
||||
<session-config>
|
||||
<session-timeout>
|
||||
30
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/* Style de la navigation */
|
||||
nav {
|
||||
background-color: #333; /* Couleur de fond sombre pour la navigation */
|
||||
background-color: #007bff; /* Couleur de fond sombre pour la navigation */
|
||||
padding: 10px 20px; /* Espacement intérieur */
|
||||
text-align: center; /* Centrer les éléments */
|
||||
}
|
||||
@@ -108,3 +108,29 @@ button[type="submit"] {
|
||||
button[type="submit"]:hover {
|
||||
background-color: #0056b3;
|
||||
}
|
||||
|
||||
table {
|
||||
border-collapse: collapse;
|
||||
width: 80%;
|
||||
margin: 20px auto;
|
||||
font-family: Arial, sans-serif;
|
||||
}
|
||||
|
||||
th, td {
|
||||
border: 1px solid #ccc;
|
||||
padding: 10px 15px;
|
||||
text-align: left;
|
||||
}
|
||||
|
||||
th {
|
||||
background-color: #2c3e50;
|
||||
color: white;
|
||||
}
|
||||
|
||||
tr:nth-child(even) {
|
||||
background-color: #f2f2f2;
|
||||
}
|
||||
|
||||
tr:hover {
|
||||
background-color: #dcdde1;
|
||||
}
|
||||
|
||||
12
src/test/java/testClient.java
Normal file
12
src/test/java/testClient.java
Normal file
@@ -0,0 +1,12 @@
|
||||
/*
|
||||
* 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
|
||||
*/
|
||||
|
||||
/**
|
||||
*
|
||||
* @author emile.malcuit
|
||||
*/
|
||||
public class testClient {
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user