commit b28dbb0fa5956bd767fca7833f47d65937cd4b15 Author: emile.malcuit Date: Mon Sep 22 14:05:52 2025 +0200 test diff --git a/nb-configuration.xml b/nb-configuration.xml new file mode 100644 index 0000000..020b24f --- /dev/null +++ b/nb-configuration.xml @@ -0,0 +1,20 @@ + + + + + + 10-web + pfv5ee8 + ide + + diff --git a/pom.xml b/pom.xml new file mode 100644 index 0000000..60cfac0 --- /dev/null +++ b/pom.xml @@ -0,0 +1,42 @@ + + 4.0.0 + com.mycompany + Test2Jakarta + 1.0-SNAPSHOT + war + Test2Jakarta-1.0-SNAPSHOT + + + UTF-8 + 10.0.0 + + + + + jakarta.platform + jakarta.jakartaee-api + ${jakartaee} + provided + + + + + + + org.apache.maven.plugins + maven-compiler-plugin + 3.8.1 + + 11 + 11 + + + + org.apache.maven.plugins + maven-war-plugin + 3.3.2 + + + + \ No newline at end of file diff --git a/src/main/java/com/mycompany/test2jakarta/JakartaRestConfiguration.java b/src/main/java/com/mycompany/test2jakarta/JakartaRestConfiguration.java new file mode 100644 index 0000000..14695f8 --- /dev/null +++ b/src/main/java/com/mycompany/test2jakarta/JakartaRestConfiguration.java @@ -0,0 +1,13 @@ +package com.mycompany.test2jakarta; + +import jakarta.ws.rs.ApplicationPath; +import jakarta.ws.rs.core.Application; + +/** + * Configures Jakarta RESTful Web Services for the application. + * @author Juneau + */ +@ApplicationPath("resources") +public class JakartaRestConfiguration extends Application { + +} diff --git a/src/main/java/com/mycompany/test2jakarta/resources/JakartaEE10Resource.java b/src/main/java/com/mycompany/test2jakarta/resources/JakartaEE10Resource.java new file mode 100644 index 0000000..f084c4a --- /dev/null +++ b/src/main/java/com/mycompany/test2jakarta/resources/JakartaEE10Resource.java @@ -0,0 +1,20 @@ +package com.mycompany.test2jakarta.resources; + +import jakarta.ws.rs.GET; +import jakarta.ws.rs.Path; +import jakarta.ws.rs.core.Response; + +/** + * + * @author + */ +@Path("jakartaee10") +public class JakartaEE10Resource { + + @GET + public Response ping(){ + return Response + .ok("ping Jakarta EE") + .build(); + } +} diff --git a/src/main/java/com/test/servlets/AcceuilServlet.java b/src/main/java/com/test/servlets/AcceuilServlet.java new file mode 100644 index 0000000..7d1bcdb --- /dev/null +++ b/src/main/java/com/test/servlets/AcceuilServlet.java @@ -0,0 +1,111 @@ +/* + * 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 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="AcceuilServlet", urlPatterns={"/Acceuil"}) +public class AcceuilServlet extends HttpServlet { + + /** + * Processes requests for both HTTP GET and POST + * 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(""); + out.println(""); + out.println(""); + out.println("Servlet AcceuilServlet"); + out.println(""); + out.println(""); + out.println("

Servlet AcceuilServlet at " + request.getContextPath() + "

"); + out.println(""); + + out.println(""); + out.println(""); + + } + } + + // + /** + * Handles the HTTP GET 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); + request.setAttribute("connect","false"); + getServletContext().getRequestDispatcher("/WEB-INF/AcceuilJSP.jsp").forward(request, response); + + } + + /** + * Handles the HTTP POST 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); + String login = request.getParameter("user_name"); + String mdp = request.getParameter("user_password"); + String test; + if (login != null && !login.isBlank()) { + test = verifConnexion(login , mdp); + request.setAttribute("login", login); + request.setAttribute("connect",test); + } + 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"; + }// + + public String verifConnexion(String id, String mdp){ + if(id.equals("alex") && mdp.equals("1234")){ + return "true"; + }else{ + return "false"; + } + }; + +} diff --git a/src/main/java/com/test/servlets/ListeServlet.java b/src/main/java/com/test/servlets/ListeServlet.java new file mode 100644 index 0000000..bb0773b --- /dev/null +++ b/src/main/java/com/test/servlets/ListeServlet.java @@ -0,0 +1,88 @@ +/* + * 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 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="ListeServlet", urlPatterns={"/ListeClients"}) +public class ListeServlet extends HttpServlet { + + /** + * Processes requests for both HTTP GET and POST + * 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(""); + out.println(""); + out.println(""); + out.println("Servlet ListeServlet"); + out.println(""); + out.println(""); + out.println("

Servlet ListeServlet at " + request.getContextPath() + "

"); + out.println(""); + out.println(""); + } + } + + // + /** + * Handles the HTTP GET 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/ListeClientsJSP.jsp").forward(request, response); + } + + /** + * Handles the HTTP POST 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"; + }// + +} diff --git a/src/main/java/com/test/servlets/NouveauServlet.java b/src/main/java/com/test/servlets/NouveauServlet.java new file mode 100644 index 0000000..389bb58 --- /dev/null +++ b/src/main/java/com/test/servlets/NouveauServlet.java @@ -0,0 +1,89 @@ +/* + * 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 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="NouveauServlet", urlPatterns={"/NouveauClient"}) +public class NouveauServlet extends HttpServlet { + + /** + * Processes requests for both HTTP GET and POST + * 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(""); + out.println(""); + out.println(""); + out.println("Servlet NouveauServlet"); + out.println(""); + out.println(""); + out.println("

Servlet NouveauServlet at " + request.getContextPath() + "

"); + out.println(""); + out.println(""); + } + } + + // + /** + * Handles the HTTP GET 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/NouveauClientJSP.jsp").forward(request, response); + + } + + /** + * Handles the HTTP POST 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"; + }// + +} diff --git a/src/main/resources/META-INF/persistence.xml b/src/main/resources/META-INF/persistence.xml new file mode 100644 index 0000000..7582bf1 --- /dev/null +++ b/src/main/resources/META-INF/persistence.xml @@ -0,0 +1,7 @@ + + + + + + + diff --git a/src/main/webapp/WEB-INF/AcceuilJSP.jsp b/src/main/webapp/WEB-INF/AcceuilJSP.jsp new file mode 100644 index 0000000..81d400b --- /dev/null +++ b/src/main/webapp/WEB-INF/AcceuilJSP.jsp @@ -0,0 +1,69 @@ +<%-- + Document : AcceuilJSP + Created on : 12 sept. 2025, 14:43:34 + Author : emile.malcuit +--%> + +<%@page contentType="text/html" pageEncoding="UTF-8"%> + + + + + JSP Page + + + + <%@include file="jspf/entete.jspf" %> + + + + + + <% + + Object connect = request.getAttribute("connect"); + Object login = request.getAttribute("login"); + if(connect.equals("true")){ + + %> + <%@include file="jspf/menu.jspf" %> +

Test ${connect}

+

Hello mon ami ${login}

+

Bienvenue sur la nouvelle application de gestion des clients + écrite avec JakartaEE

+ <% + }else{ + %> + +
+
+

Formulaire de connexion

+
+
    + +
    + + +
    +
    +
    + +
    +
+
+
+
+ <% + } + %> + + + diff --git a/src/main/webapp/WEB-INF/ListeClientsJSP.jsp b/src/main/webapp/WEB-INF/ListeClientsJSP.jsp new file mode 100644 index 0000000..8973325 --- /dev/null +++ b/src/main/webapp/WEB-INF/ListeClientsJSP.jsp @@ -0,0 +1,23 @@ +<%-- + Document : ListeClients + Created on : 12 sept. 2025, 14:14:56 + Author : emile.malcuit +--%> + +<%@page contentType="text/html" pageEncoding="UTF-8"%> + + + + + Leste des Clients + + + + <%@include file="jspf/entete.jspf" %> + <%@include file="jspf/menu.jspf" %> +

Hello World!

+

Liste des clients +
+ Page en construction

+ + diff --git a/src/main/webapp/WEB-INF/NouveauClientJSP.jsp b/src/main/webapp/WEB-INF/NouveauClientJSP.jsp new file mode 100644 index 0000000..23db03d --- /dev/null +++ b/src/main/webapp/WEB-INF/NouveauClientJSP.jsp @@ -0,0 +1,23 @@ +<%-- + Document : NouveauClient + Created on : 12 sept. 2025, 14:14:45 + Author : emile.malcuit +--%> + +<%@page contentType="text/html" pageEncoding="UTF-8"%> + + + + + Nouveau Client + + + + <%@include file="jspf/entete.jspf" %> + <%@include file="jspf/menu.jspf" %> +

Bonjour Les Zouaves

+

Création d’un nouveau client +
+ Page en construction

+ + diff --git a/src/main/webapp/WEB-INF/beans.xml b/src/main/webapp/WEB-INF/beans.xml new file mode 100644 index 0000000..9dfae34 --- /dev/null +++ b/src/main/webapp/WEB-INF/beans.xml @@ -0,0 +1,6 @@ + + + \ No newline at end of file diff --git a/src/main/webapp/WEB-INF/index.html b/src/main/webapp/WEB-INF/index.html new file mode 100644 index 0000000..3368e9c --- /dev/null +++ b/src/main/webapp/WEB-INF/index.html @@ -0,0 +1,10 @@ + + + + Start Page + + + +

Hello World!

+ + diff --git a/src/main/webapp/WEB-INF/jspf/entete.jspf b/src/main/webapp/WEB-INF/jspf/entete.jspf new file mode 100644 index 0000000..74e131a --- /dev/null +++ b/src/main/webapp/WEB-INF/jspf/entete.jspf @@ -0,0 +1,4 @@ +<%-- any content can be specified here e.g.: --%> +<%@ page pageEncoding="UTF-8" %> +

Gestion des clients

+
diff --git a/src/main/webapp/WEB-INF/jspf/menu.jspf b/src/main/webapp/WEB-INF/jspf/menu.jspf new file mode 100644 index 0000000..b2bda20 --- /dev/null +++ b/src/main/webapp/WEB-INF/jspf/menu.jspf @@ -0,0 +1,7 @@ +<%-- any content can be specified here e.g.: --%> +<%@ page pageEncoding="UTF-8" %> + diff --git a/src/main/webapp/WEB-INF/web.xml b/src/main/webapp/WEB-INF/web.xml new file mode 100644 index 0000000..02193b0 --- /dev/null +++ b/src/main/webapp/WEB-INF/web.xml @@ -0,0 +1,32 @@ + + + + AcceuilServlet + com.test.servlets.AcceuilServlet + + + NouveauServlet + com.test.servlets.NouveauServlet + + + ListeServlet + com.test.servlets.ListeServlet + + + AcceuilServlet + /Acceuil + + + NouveauServlet + /NouveauClient + + + ListeServlet + /ListeClients + + + + 30 + + + diff --git a/src/main/webapp/style/style.css b/src/main/webapp/style/style.css new file mode 100644 index 0000000..eb1f58a --- /dev/null +++ b/src/main/webapp/style/style.css @@ -0,0 +1,110 @@ +/* Style de la navigation */ +nav { + background-color: #333; /* Couleur de fond sombre pour la navigation */ + padding: 10px 20px; /* Espacement intérieur */ + text-align: center; /* Centrer les éléments */ +} + +/* Style pour les liens dans la navigation */ +nav a { + color: white; /* Couleur du texte (blanc) */ + text-decoration: none; /* Supprimer le soulignement des liens */ + margin: 0 15px; /* Espacement entre les liens */ + font-size: 16px; /* Taille de police des liens */ + padding: 10px 15px; /* Padding autour du texte */ + border-radius: 5px; /* Coins arrondis pour les liens */ + transition: background-color 0.3s ease; /* Transition pour l'effet hover */ +} + +/* Effet au survol des liens */ +nav a:hover { + background-color: #555; /* Changer la couleur de fond au survol */ +} + +/* Effet actif sur le lien sélectionné */ +nav a:active { + background-color: #444; /* Couleur de fond quand le lien est cliqué */ +} + +/* Style global du body */ +body { + font-family: Arial, sans-serif; + background: #f0f2f5; + display: flex; + flex-direction: column; + justify-content: center; + align-items: center; + height: 100vh; + margin: 0; +} + +/* Container du formulaire de connexion */ +.form-glob { + background-color: #fff; + padding: 30px 40px; + border-radius: 10px; + box-shadow: 0 4px 20px rgba(0, 0, 0, 0.1); + width: 350px; +} + +/* Titre du formulaire */ +.form-glob h2 { + margin-bottom: 25px; + color: #333; + text-align: center; +} + +/* Reset de la liste (même avec