This commit is contained in:
emile.malcuit
2025-09-22 14:05:52 +02:00
commit b28dbb0fa5
17 changed files with 674 additions and 0 deletions

20
nb-configuration.xml Normal file
View File

@@ -0,0 +1,20 @@
<?xml version="1.0" encoding="UTF-8"?>
<project-shared-configuration>
<!--
This file contains additional configuration written by modules in the NetBeans IDE.
The configuration is intended to be shared among all the users of project and
therefore it is assumed to be part of version control checkout.
Without this configuration present, some functionality in the IDE may be limited or fail altogether.
-->
<properties xmlns="http://www.netbeans.org/ns/maven-properties-data/1">
<!--
Properties that influence various parts of the IDE, especially code formatting and the like.
You can copy and paste the single properties, into the pom.xml file and the IDE will pick them up.
That way multiple projects can share the same settings (useful for formatting rules for example).
Any value defined here will override the pom.xml file value but is only applicable to the current project.
-->
<org-netbeans-modules-maven-j2ee.netbeans_2e_hint_2e_j2eeVersion>10-web</org-netbeans-modules-maven-j2ee.netbeans_2e_hint_2e_j2eeVersion>
<org-netbeans-modules-maven-j2ee.netbeans_2e_hint_2e_deploy_2e_server>pfv5ee8</org-netbeans-modules-maven-j2ee.netbeans_2e_hint_2e_deploy_2e_server>
<org-netbeans-modules-maven-jaxws.rest_2e_config_2e_type>ide</org-netbeans-modules-maven-jaxws.rest_2e_config_2e_type>
</properties>
</project-shared-configuration>

42
pom.xml Normal file
View File

@@ -0,0 +1,42 @@
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.mycompany</groupId>
<artifactId>Test2Jakarta</artifactId>
<version>1.0-SNAPSHOT</version>
<packaging>war</packaging>
<name>Test2Jakarta-1.0-SNAPSHOT</name>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<jakartaee>10.0.0</jakartaee>
</properties>
<dependencies>
<dependency>
<groupId>jakarta.platform</groupId>
<artifactId>jakarta.jakartaee-api</artifactId>
<version>${jakartaee}</version>
<scope>provided</scope>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.8.1</version>
<configuration>
<source>11</source>
<target>11</target>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
<version>3.3.2</version>
</plugin>
</plugins>
</build>
</project>

View File

@@ -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 {
}

View File

@@ -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();
}
}

View File

@@ -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 <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 AcceuilServlet</title>");
out.println("</head>");
out.println("<body>");
out.println("<h1>Servlet AcceuilServlet at " + request.getContextPath() + "</h1>");
out.println("");
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);
request.setAttribute("connect","false");
getServletContext().getRequestDispatcher("/WEB-INF/AcceuilJSP.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);
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";
}// </editor-fold>
public String verifConnexion(String id, String mdp){
if(id.equals("alex") && mdp.equals("1234")){
return "true";
}else{
return "false";
}
};
}

View File

@@ -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 <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);
getServletContext().getRequestDispatcher("/WEB-INF/ListeClientsJSP.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,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 <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/NouveauClientJSP.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,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<persistence version="3.0" xmlns="https://jakarta.ee/xml/ns/persistence" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="https://jakarta.ee/xml/ns/persistence https://jakarta.ee/xml/ns/persistence/persistence_3_0.xsd">
<!-- Define Persistence Unit -->
<persistence-unit name="my_persistence_unit">
</persistence-unit>
</persistence>

View File

@@ -0,0 +1,69 @@
<%--
Document : AcceuilJSP
Created on : 12 sept. 2025, 14:43:34
Author : emile.malcuit
--%>
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>JSP Page</title>
<link href="style/style.css" rel="stylesheet">
</head>
<%@include file="jspf/entete.jspf" %>
<body>
<!--<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")){
%>
<%@include file="jspf/menu.jspf" %>
<p>Test ${connect}</p>
<h1>Hello mon ami ${login}</h1>
<p>Bienvenue sur la nouvelle application de gestion des clients
écrite avec JakartaEE</p>
<%
}else{
%>
<form action="http://localhost:8080/Test2Jakarta/Acceuil" method="post">
<div class="form-glob">
<h2>Formulaire de connexion</h2>
<div class="connexion">
<ul>
<div class="login">
<label for="login">Nom :</label>
<input type="text" id="login" name="user_name" />
<br>
</div>
<div class="mdp">
<label for="mdp">Mot de passe :</label>
<input type="text" id="mdp" name="user_password" />
<br>
</div><!-- comment -->
<div class="valider">
<button type="submit">Se connecter</button>
</div>
</ul>
</div>
</div>
</form>
<%
}
%>
</body>
</html>

View File

@@ -0,0 +1,23 @@
<%--
Document : ListeClients
Created on : 12 sept. 2025, 14:14:56
Author : emile.malcuit
--%>
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Leste des Clients</title>
<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
</br>
Page en construction</p>
</body>
</html>

View File

@@ -0,0 +1,23 @@
<%--
Document : NouveauClient
Created on : 12 sept. 2025, 14:14:45
Author : emile.malcuit
--%>
<%@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>
<link href="style/style.css" rel="stylesheet">
</head>
<body>
<%@include file="jspf/entete.jspf" %>
<%@include file="jspf/menu.jspf" %>
<h1>Bonjour Les Zouaves</h1>
<p>Création dun nouveau client
</br>
Page en construction</p>
</body>
</html>

View File

@@ -0,0 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<beans 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/beans_4_0.xsd"
bean-discovery-mode="all">
</beans>

View File

@@ -0,0 +1,10 @@
<!DOCTYPE html>
<html>
<head>
<title>Start Page</title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
</head>
<body>
<h1>Hello World!</h1>
</body>
</html>

View File

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

View File

@@ -0,0 +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>
</nav>

View File

@@ -0,0 +1,32 @@
<?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>AcceuilServlet</servlet-name>
<servlet-class>com.test.servlets.AcceuilServlet</servlet-class>
</servlet>
<servlet>
<servlet-name>NouveauServlet</servlet-name>
<servlet-class>com.test.servlets.NouveauServlet</servlet-class>
</servlet>
<servlet>
<servlet-name>ListeServlet</servlet-name>
<servlet-class>com.test.servlets.ListeServlet</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>AcceuilServlet</servlet-name>
<url-pattern>/Acceuil</url-pattern>
</servlet-mapping>
<servlet-mapping>
<servlet-name>NouveauServlet</servlet-name>
<url-pattern>/NouveauClient</url-pattern>
</servlet-mapping>
<servlet-mapping>
<servlet-name>ListeServlet</servlet-name>
<url-pattern>/ListeClients</url-pattern>
</servlet-mapping>
<session-config>
<session-timeout>
30
</session-timeout>
</session-config>
</web-app>

View File

@@ -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 <ul>) */
.connexion ul {
list-style-type: none;
padding: 0;
margin: 0;
}
/* Conteneur des champs de formulaire */
.login,
.mdp,
.valider {
margin-bottom: 20px;
}
/* Styles des labels */
label {
display: block;
margin-bottom: 6px;
color: #555;
font-weight: bold;
}
/* Styles des champs de texte */
input[type="text"] {
width: 100%;
padding: 10px;
border: 1px solid #ccc;
border-radius: 5px;
transition: border-color 0.3s;
}
/* Effet focus sur les champs de texte */
input[type="text"]:focus {
border-color: #007bff;
outline: none;
}
/* Style du bouton de soumission */
button[type="submit"] {
width: 100%;
padding: 12px;
background-color: #007bff;
color: white;
border: none;
border-radius: 5px;
font-weight: bold;
cursor: pointer;
transition: background-color 0.3s;
}
/* Effet au survol du bouton de soumission */
button[type="submit"]:hover {
background-color: #0056b3;
}