Skip to content
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package forms;
import beans.Article;
import beans.Person;
import dao.DaoPerson;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;
import libs.PasswordAuthentication;
/**
*
* @author Tutur
*/
public class ArticleFormChecker extends FormChecker<Article>{
public ArticleFormChecker(HttpServletRequest req) {
super(new Article(), req);
}
@Override
public Article checkForm() {
String title = req.getParameter("title");
String content = req.getParameter("content");
HttpSession session = req.getSession();
Person personSession = (Person) session.getAttribute("bean");
System.out.println(personSession.getLogin());
bean.setTitle(title);
bean.setContent(content);
bean.setAuthor(personSession.getLogin());
bean.setActive(Boolean.TRUE);
if(title.trim().length() < 1) {
errors.put("title", new RuntimeException("Le titre doit contenir au moins un caractère"));
}
if(content.trim().length() < 1) {
errors.put("content", new RuntimeException("Le contenu doit contenir au moins un caractère"));
}
return bean;
}
}
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package forms;
import beans.Person;
import dao.DaoPerson;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;
import libs.PasswordAuthentication;
/**
*
* @author Tutur
*/
public class ChangePwdFormChecker extends FormChecker<Person>{
public ChangePwdFormChecker(HttpServletRequest request) {
super(new Person(), request);
}
@Override
public Person checkForm() {
DaoPerson daoP = new DaoPerson();
HttpSession session = req.getSession();
String password = req.getParameter("password");
String newPassword = req.getParameter("newPassword");
String confirm = req.getParameter("confirm");
bean.setPassword(newPassword);
Person personSession = (Person) session.getAttribute("bean");
if(newPassword.length() < 3) {
errors.put("newPassword", new RuntimeException("mot de passe trop court, minimum 3 lettres"));
}
if(!(password.equals(personSession.getPassword()))) {
errors.put("password", new RuntimeException("Mot de passe incorrect"));
}
if(!newPassword.equals(confirm)){
errors.put("confirm", new RuntimeException("Les mots de passe de correspondent pas"));
}
return bean;
}
}
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package forms;
import beans.Bean;
import java.util.HashMap;
import java.util.Map;
import javax.servlet.http.HttpServletRequest;
/**
*
* @author Tutur
*/
public abstract class FormChecker<T extends Bean> {
protected T bean;
protected Map<String, RuntimeException> errors;
protected HttpServletRequest req;
/**
* Constructeur.
*
* @param bean Le bean à retourner après vérification
* @param form Le container présentant le formulaire à vérifier
*/
public FormChecker(T bean,HttpServletRequest request) {
this.bean = bean;
this.errors = new HashMap<>();
this.req = request;
}
/**
* Getter.
*
* @return Le dictionnaire des erreurs. La clé est le champ en erreur, la
* valeur est une FormException.
*/
public Map<String, RuntimeException> getErrors() {
return errors;
}
/**
* Méthode de vérification du formulaire. Contient tous les tests
* nécessaires et retourne un bean préconstruit avec les valeurs du
* formulaires.
*
* @return Le bean construit avec les données du formulaire.
*/
public abstract T checkForm();
}
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package forms;
import beans.Person;
import dao.DaoPerson;
import javax.servlet.http.HttpServletRequest;
import libs.PasswordAuthentication;
/**
*
* @author Tutur
*/
public class LoginFormChecker extends FormChecker<Person> {
public LoginFormChecker(HttpServletRequest request) {
super(new Person(), request);
}
@Override
public Person checkForm() {
String login = req.getParameter("login");
String password = req.getParameter("password");
bean.setLogin(login);
bean.setPassword(password);
DaoPerson daoP = new DaoPerson();
Person personFound = daoP.searchPersonFromLogin(bean);
PasswordAuthentication pa = new PasswordAuthentication();
if(personFound == null) {
errors.put("login", new RuntimeException("Utilisateur inexistant"));
}
else {
if(!(pa.authenticate(bean.getPassword().toCharArray(), personFound.getPassword()))){
errors.put("password", new RuntimeException("Mot de passe incorrect"));
}
}
return bean;
}
}
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package forms;
import beans.Person;
import dao.DaoPerson;
import javax.servlet.http.HttpServletRequest;
import libs.PasswordAuthentication;
/**
*
* @author Tutur
*/
public class LogonFormChecker extends FormChecker<Person>{
public LogonFormChecker(HttpServletRequest request) {
super(new Person(),request);
}
@Override
public Person checkForm() {
String login = req.getParameter("login");
String password = req.getParameter("password");
String confirm = req.getParameter("confirm");
bean.setLogin(login);
PasswordAuthentication pa = new PasswordAuthentication();
bean.setPassword(pa.hash(password.toCharArray()));
if(login.trim().length() < 3) {
errors.put("login", new RuntimeException("Login trop court, minimum 3 lettres"));
}
if(password.length() < 3) {
errors.put("password", new RuntimeException("Mot de passe trop court, minimum 3 caractères"));
}
if(!password.equals(confirm)){
errors.put("confirm", new RuntimeException("Les mots de passe de correspondent pas"));
}
if(errors.isEmpty()) {
DaoPerson daoP = new DaoPerson();
Person person = null;
person = daoP.searchPersonFromLogin(bean);
if(!(person == null)) {
errors.put("login", new RuntimeException("Login déjà existant"));
}
}
return bean;
}
}
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package libs;
import java.io.IOException;
import java.io.InputStream;
import java.util.Properties;
import java.util.logging.Level;
import java.util.logging.Logger;
/**
*
* @author Tutur
*/
public class Helpers {
private static Properties config;
public static Properties getConfig() {
if(config == null) {
try {
InputStream is = Helpers.class.getResourceAsStream("/config.properties");
config = new Properties();
config.load(is);
} catch (IOException ex) {
throw new RuntimeException("Configuration non trouvée");
}
}
return config;
}
}
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package libs;
import java.security.NoSuchAlgorithmException;
import java.security.SecureRandom;
import java.security.spec.InvalidKeySpecException;
import java.security.spec.KeySpec;
import java.util.Arrays;
import java.util.Base64;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import javax.crypto.SecretKeyFactory;
import javax.crypto.spec.PBEKeySpec;
/**
*
* @author Tutur
*/
public final class PasswordAuthentication {
private static final String INIT_ID = "51";
/**
* Each token produced by this class uses this identifier as a prefix.
*/
public static final String ID = "$" + INIT_ID + "$";
/**
* The minimum recommended cost, used by default
*/
public static final int DEFAULT_COST = 16;
private static final String ALGORITHM = "PBKDF2WithHmacSHA512";
private static final int SIZE = 128;
private static final Pattern LAYOUT = Pattern.compile("\\$" + INIT_ID + "\\$(\\d\\d?)\\$(.{43})");
private final SecureRandom random;
private final int cost;
/**
* Create a password manager with a default cost
*/
public PasswordAuthentication() {
this(DEFAULT_COST);
}
/**
* Create a password manager with a specified cost
*
* @param cost the exponential computational cost of hashing a password, 0
* to 30
*/
public PasswordAuthentication(int cost) {
iterations(cost);
/* Validate cost */
this.cost = cost;
this.random = new SecureRandom();
}
private static int iterations(int cost) {
if ((cost < 0) || (cost > 30)) {
throw new IllegalArgumentException("cost: " + cost);
}
return 1 << cost; // Décalage du bit à gauche : 0001 << 3 revient à 1000
}
/**
* Hash a password for storage.
*
* @param password The password to hash
* @return a secure authentication token to be stored for later
* authentication
*/
public String hash(char[] password) {
byte[] salt = new byte[SIZE / 8];
random.nextBytes(salt);
byte[] dk = pbkdf2(password, salt, 1 << cost);
byte[] hash = new byte[salt.length + dk.length];
System.arraycopy(salt, 0, hash, 0, salt.length);
System.arraycopy(dk, 0, hash, salt.length, dk.length);
Base64.Encoder enc = Base64.getUrlEncoder().withoutPadding();
return ID + cost + '$' + enc.encodeToString(hash);
}
/**
* Authenticate with a password and a stored password token.
*
* @param password The password to compare
* @param token The token to compare the password to
* @return true if the password and token match
*/
public boolean authenticate(char[] password, String token) {
Matcher m = LAYOUT.matcher(token);
if (!m.matches()) {
throw new IllegalArgumentException("Invalid token format");
}
int iterations = iterations(Integer.parseInt(m.group(1)));
byte[] hash = Base64.getUrlDecoder().decode(m.group(2));
byte[] salt = Arrays.copyOfRange(hash, 0, SIZE / 8);
byte[] check = pbkdf2(password, salt, iterations);
int zero = 0;
for (int idx = 0; idx < check.length; ++idx) {
zero |= hash[salt.length + idx] ^ check[idx];
}
return zero == 0;
}
private static byte[] pbkdf2(char[] password, byte[] salt, int iterations) {
KeySpec spec = new PBEKeySpec(password, salt, iterations, SIZE);
try {
SecretKeyFactory f = SecretKeyFactory.getInstance(ALGORITHM);
return f.generateSecret(spec).getEncoded();
} catch (NoSuchAlgorithmException ex) {
throw new IllegalStateException("Missing algorithm: " + ALGORITHM, ex);
} catch (InvalidKeySpecException ex) {
throw new IllegalStateException("Invalid SecretKeyFactory", ex);
}
}
/**
* Hash a password in an immutable {@code String}.
*
* <p>
* Passwords should be stored in a {@code char[]} so that it can be filled
* with zeros after use instead of lingering on the heap and elsewhere.
*
* @param password The password to hash
* @return a secure authentication token to be stored for later
* authentication
* @deprecated Use {@link #hash(char[])} instead
*/
@Deprecated
public String hash(String password) {
return hash(password.toCharArray());
}
}
driver=org.mariadb.jdbc.Driver
protocol=jdbc:mariadb
host=localhost
port=3306
dbname=Blog
login=blog
password=blog
usertable=blog_person
articletable=article
<%--
Document : adminIndex
Created on : 21 sept. 2023, 14:25:59
Author : Tutur
--%>
<%@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>Administer le site</title>
<link rel="stylesheet" href='<c:url value="./assets/css/style.css"/>'>
</head>
<body>
<header>
<ul>
<c:choose>
<c:when test="${empty sessionScope.bean}">
<li><a href="<c:url value="/login"/>">Se connecter</a></li>
<li> <a href="<c:url value="/logon"/>">S'inscrire</a></li>
</c:when>
<c:when test="${sessionScope.bean.login} == 'admin'">
<li> <a href="<c:url value="/admin"/>">Administrer le site</a></li>
</c:when>
<c:otherwise>
<li><a href="<c:url value="/logout"/>">Se déconnecter</a></li>
<li> <a href="<c:url value="/profil"/>">Mon profil</a></li>
<li> <a href="<c:url value="/createArticle"/>">Créer un article</a></li>
</c:otherwise>
</c:choose>
<li><a href="<c:url value="/articles"></c:url>">Articles</a></li>
</ul>
<h1>Bienvenue sur mon blog ${sessionScope.bean.login}</h1>
</header>
<main>
<h2>Les utilisateurs</h2>
<table>
<tr>
<th>ID</th>
<th>Login</th>
<th>Gérer</th>
</tr>
<c:forEach items="${requestScope.users}" var="user">
<c:if test="${user.login != 'admin'}">
<tr>
<td>${user.id}</td>
<td>${user.login}</td>
<td>
<button><a class="danger" href="<c:url value='/admin/deleteUser?id=${user.id}'/>">Supprimer</a></button>
</td>
</tr>
</c:if>
</c:forEach>
</table>
<h2>Les articles</h2>
<table>
<tr>
<th>ID</th>
<th>Titre</th>
<th>Contenu</th>
<th>Date création</th>
<th>Auteur</th>
</tr>
<c:forEach items="${requestScope.articles}" var="article">
<tr>
<td>${article.id_article}</td>
<td>${article.title}</td>
<td>${article.content}</td>
<td>${article.created}</td>
<td>${article.author}</td>
<td>
<button><a class="danger" href="<c:url value="/admin/deleteArticle?id=${article.id}"></c:url>">Supprimer</a></button>
</td>
</tr>
</c:forEach>
</table>
</main>
<footer>
&copy;Moi
Propulser par Java EE
</footer>
</body>
</html>
<%--
Document : articles
Created on : 21 sept. 2023, 09:43:34
Author : Tutur
--%>
<%@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>Les Articles</title>
<link rel="stylesheet" href='<c:url value="./assets/css/style.css"/>'>
</head>
<body>
<header>
<ul>
<c:choose>
<c:when test="${empty sessionScope.bean}">
<li><a href="<c:url value="/login"/>">Se connecter</a></li>
<li> <a href="<c:url value="/logon"/>">S'inscrire</a></li>
</c:when>
<c:when test="${sessionScope.bean.login == 'admin'}">
<li><a href="<c:url value="/logout"/>">Se déconnecter</a></li>
<li> <a href="<c:url value="/profil"/>">Mon profil</a></li>
<li> <a href="<c:url value="/createArticle"/>">Créer un article</a></li>
<li> <a href="<c:url value="/admin"/>">Administrer le site</a></li>
</c:when>
<c:otherwise>
<li><a href="<c:url value="/logout"/>">Se déconnecter</a></li>
<li> <a href="<c:url value="/profil"/>">Mon profil</a></li>
<li> <a href="<c:url value="/createArticle"/>">Créer un article</a></li>
</c:otherwise>
</c:choose>
<li><a href="<c:url value="/articles"></c:url>">Articles</a></li>
</ul>
</header>
<main>
<h2>Voici les 10 derniers articles : </h2>
<div class="bloc-article">
<c:forEach var="article" items="${requestScope.articles}">
<div class="article">
<h2>${article.title}</h2>
<p>${article.content}</p>
<p>Par ${article.author}</p>
<p>Crée le ${article.created}</p>
</div>
</c:forEach>
</div>
</main>
<footer>
&copy;Moi
Propulser par Java EE
</footer>
</body>
</html>
<%--
Document : login
Created on : 18 sept. 2023, 10:47:58
Author : Tutur
--%>
<%@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>Créer un article</title>
<link rel="stylesheet" href='<c:url value="./assets/css/style.css"/>'>
</head>
<body>
<header>
<ul>
<c:choose>
<c:when test="${empty sessionScope.bean}">
<li><a href="<c:url value="/login"/>">Se connecter</a></li>
<li> <a href="<c:url value="/logon"/>">S'inscrire</a></li>
</c:when>
<c:when test="${sessionScope.bean.login == 'admin'}">
<li><a href="<c:url value="/logout"/>">Se déconnecter</a></li>
<li> <a href="<c:url value="/profil"/>">Mon profil</a></li>
<li> <a href="<c:url value="/createArticle"/>">Créer un article</a></li>
<li> <a href="<c:url value="/admin"/>">Administrer le site</a></li>
</c:when>
<c:otherwise>
<li><a href="<c:url value="/logout"/>">Se déconnecter</a></li>
<li> <a href="<c:url value="/profil"/>">Mon profil</a></li>
<li> <a href="<c:url value="/createArticle"/>">Créer un article</a></li>
</c:otherwise>
</c:choose>
</ul>
</header>
<main>
<form action="<c:url value="/createArticle"/>" method="post">
<div>
<label for="title">Titre</label>
<input type="text" id="title" name="title" value="<c:out value="${requestScope.bean.title}"/>">
</div>
<span class="error">${requestScope.errors.title.message}</span>
<div>
<label for="content">Contenu</label>
<textarea id="content" name="content" rows="5" cols="30"></textarea>
</div>
<span class="error">${requestScope.errors.content.message}</span>
<div>
<input type="submit" value="Envoyer">
<input type="reset" value="Annuler">
</div>
</form>
</main>
<footer>
&copy;Moi
Propulser par Java EE
</footer>
</body>
</html>
<%-- any content can be specified here e.g.: --%>
<%@ page pageEncoding="UTF-8" %>
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%--
Document : login
Created on : 18 sept. 2023, 15:31:04
Author : Tutur
--%>
<%@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>Login page</title>
<link rel="stylesheet" href='<c:url value="./assets/css/style.css"/>'>
</head>
<body>
<header>
<ul>
<c:choose>
<c:when test="${empty sessionScope.bean}">
<li><a href="<c:url value="/login"/>">Se connecter</a></li>
<li> <a href="<c:url value="/logon"/>">S'inscrire</a></li>
</c:when>
<c:when test="${sessionScope.role.description} = 'admin'">
<li> <a href="<c:url value="/admin"/>">Administrer le site</a></li>
</c:when>
<c:otherwise>
<li><a href="<c:url value="/logout"/>">Se déconnecter</a></li>
<li> <a href="<c:url value="/profil"/>">Mon profil</a></li>
<li> <a href="<c:url value="/createArticle"/>">Créer un article</a></li>
</c:otherwise>
</c:choose>
</ul>
<h1>Bienvenue sur mon blog</h1>
</header>
<main>
<form action="<c:url value="/login"/>" method="post">
<div>
<label for="login">Login</label>
<input type="text" id="login" name="login" value="<c:out value="${requestScope.bean.login}"/>">
</div>
<span class="error">${requestScope.errors.login.message}</span>
<div>
<label for="password">Password</label>
<input type="password" id="password" name="password">
</div>
<span class="error">${requestScope.errors.password.message}</span>
<div>
<input type="submit" value="Envoyer">
<input type="reset" value="Annuler">
</div>
</form>
</main>
<footer>
&copy;Moi
Propulser par Java EE
</footer>
</body>
</html>
<%--
Document : login
Created on : 18 sept. 2023, 10:47:58
Author : Tutur
--%>
<%@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>Logon page</title>
<link rel="stylesheet" href='<c:url value="./assets/css/style.css"/>'>
</head>
<body>
<header>
<ul>
<c:choose>
<c:when test="${empty sessionScope.bean}">
<li><a href="<c:url value="/login"/>">Se connecter</a></li>
<li> <a href="<c:url value="/logon"/>">S'inscrire</a></li>
</c:when>
<c:when test="${sessionScope.role.description} = 'admin'">
<li> <a href="<c:url value="/admin"/>">Administrer le site</a></li>
</c:when>
<c:otherwise>
<li><a href="<c:url value="/logout"/>">Se déconnecter</a></li>
<li> <a href="<c:url value="/profil"/>">Mon profil</a></li>
<li> <a href="<c:url value="/createArticle"/>">Créer un article</a></li>
</c:otherwise>
</c:choose>
</ul>
<h1>Bienvenue sur mon blog ${sessionScopeScope.bean.login}</h1>
</header>
<main>
<form action="<c:url value="/logon"/>" method="post">
<div>
<label for="login">Login</label>
<input type="text" id="login" name="login" value="<c:out value="${requestScope.bean.login}"/>">
</div>
<span class="error">${requestScope.errors.login.message}</span>
<div>
<label for="password">Password</label>
<input type="password" id="password" name="password">
</div>
<span class="error">${requestScope.errors.password.message}</span>
<div>
<label for="password">Confirmer</label>
<input type="password" id="confirm" name="confirm">
</div>
<span class="error">${requestScope.errors.confirm.message}</span>
<div>
<input type="submit" value="Envoyer">
<input type="reset" value="Annuler">
</div>
</form>
</main>
<footer>
&copy;Moi
Propulser par Java EE
</footer>
</body>
</html>
<%--
Document : profil
Created on : 21 sept. 2023, 10:09:55
Author : Tutur
--%>
<%@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>Mon profil</title>
<link rel="stylesheet" href='<c:url value="./assets/css/style.css"/>'>
</head>
<body>
<header>
<ul>
<c:choose>
<c:when test="${empty sessionScope.bean}">
<li><a href="<c:url value="/login"/>">Se connecter</a></li>
<li> <a href="<c:url value="/logon"/>">S'inscrire</a></li>
</c:when>
<c:when test="${sessionScope.bean.login == 'admin'}">
<li><a href="<c:url value="/logout"/>">Se déconnecter</a></li>
<li> <a href="<c:url value="/profil"/>">Mon profil</a></li>
<li> <a href="<c:url value="/createArticle"/>">Créer un article</a></li>
<li> <a href="<c:url value="/admin"/>">Administrer le site</a></li>
</c:when>
<c:otherwise>
<li><a href="<c:url value="/logout"/>">Se déconnecter</a></li>
<li> <a href="<c:url value="/profil"/>">Mon profil</a></li>
<li> <a href="<c:url value="/createArticle"/>">Créer un article</a></li>
</c:otherwise>
</c:choose>
<li><a href="<c:url value="/articles"></c:url>">Articles</a></li>
</ul>
<h1>Tu es sur le profil de ${sessionScope.bean.login}</h1>
</header>
<main>
<div class="bloc-profil">
<form action="<c:url value="/profil"/>" method="post">
<div>
<label for="password">Password</label>
<input type="password" id="password" name="password">
</div>
<span class="error">${requestScope.errors.password.message}</span>
<div>
<label for="newPassword"> New Password</label>
<input type="password" id="newPassword" name="newPassword">
</div>
<span class="error">${requestScope.errors.newPassword.message}</span>
<div>
<label for="password">Confirmer</label>
<input type="password" id="confirm" name="confirm">
</div>
<span class="error">${requestScope.errors.confirm.message}</span>
<div>
<input type="submit" value="Envoyer">
<input type="reset" value="Annuler">
</div>
</form>
<div class="article-profil">
<c:forEach items="${requestScope.userArticles}" var="article">
<div class="article">
<h2>${article.title}</h2>
<p>${article.content}</p>
<p>Par ${article.author}</p>
<p>Crée le ${article.created}</p>
</div>
</c:forEach>
</div>
</div>
</main>
<footer>
&copy;Moi
Propulser par Java EE
</footer>
</body>
</html>
<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns="http://xmlns.jcp.org/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-app_3_1.xsd"
version="3.1">
<session-config>
<session-timeout>
30
</session-timeout>
</session-config>
</web-app>
/*
To change this license header, choose License Headers in Project Properties.
To change this template file, choose Tools | Templates
and open the template in the editor.
*/
/*
Created on : 18 sept. 2023, 09:19:55
Author : Tutur
*/
body{
display: flex;
align-items: center;
flex-direction: column;
text-align: center;
background: linear-gradient(to left top,red,blue);
background-repeat: no-repeat;
height: 100%;
}
html{
height: 100%;
}
main{
display: flex;
align-items: center;
justify-content: center;
flex-direction: column;
height: 100%;
width: 100%;
}
a{
text-decoration: none;
color: black;
}
li{
list-style: none;
font-size: 25px;
padding-right: 20px;
}
ul{
display: flex;
}
header{
width: 100%;
display: flex;
flex-direction: column;
align-items: center;
}
form{
display: flex;
flex-direction: column;
align-items: flex-start;
justify-content: space-around;
height: 67%;
font-size: 24px;
width: 40%;
}
form>div{
width: 100%;
display: flex;
justify-content: space-between;
}
form>div:nth-of-type(4){
justify-content: space-around;
}
footer{
position: absolute;
bottom: 0;
}
.error{
color: red;
font-style: italic;
font-size: 18px;
}
textarea{
}
.bloc-article{
display: flex;
flex-wrap: wrap;
justify-content: space-around;
}
.article{
width: 30%;
}
.article>p{
margin-bottom: 8px;
margin-top: 8px;
}
table{
font-size: 20px;
}
.bloc-profil{
display: flex;
justify-content: space-around;
width: 100%;
height: 100%;
}
.bloc-profil>form{
width: 40%;
}
.article-profil{
width: 40%;
display: flex;
flex-wrap: wrap;
}
.second-main{
height: 100%;
}
\ No newline at end of file
...@@ -5,13 +5,53 @@ ...@@ -5,13 +5,53 @@
--%> --%>
<%@page contentType="text/html" pageEncoding="UTF-8"%> <%@page contentType="text/html" pageEncoding="UTF-8"%>
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<!DOCTYPE html> <!DOCTYPE html>
<html> <html>
<head> <head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Acceuil</title> <title>Acceuil</title>
<link rel="stylesheet" href='<c:url value="./assets/css/style.css"/>'>
</head> </head>
<body> <body>
<h1>Bienvenue sur mon blog</h1> <header>
<ul>
<c:choose>
<c:when test="${empty sessionScope.bean}">
<li><a href="<c:url value="/login"/>">Se connecter</a></li>
<li> <a href="<c:url value="/logon"/>">S'inscrire</a></li>
</c:when>
<c:otherwise>
<li><a href="<c:url value="/logout"/>">Se déconnecter</a></li>
<li> <a href="<c:url value="/profil"/>">Mon profil</a></li>
<li> <a href="<c:url value="/createArticle"/>">Créer un article</a></li>
<li> <a href="<c:url value="/admin"/>">Administrer le site</a></li>
</c:otherwise>
</c:choose>
<li><a href="<c:url value="/articles"></c:url>">Articles</a></li>
</ul>
<h1>Bienvenue sur mon blog ${sessionScope.bean.login}</h1>
</header>
<main>
<div class="second-main">
<artcile>
<h2 class="atitle">Titre</h2>
<p class="asubtitle">Créer le 18 septembre 2023 par Tutur</p>
<div class="abody">
Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.
</div>
</artcile>
</div>
</main>
<footer>
&copy;Moi
Propulser par Java EE
</footer>
</body> </body>
</html> </html>