Skip to content
GitLab
Explore
Sign in
Register
Commits on Source (3)
ajout d'un Menu dynamique
· 3e28fe9a
Ramzi BENMANSOUR
authored
May 05, 2023
3e28fe9a
Profil ajouté
· 17a4ced3
Ramzi BENMANSOUR
authored
May 05, 2023
17a4ced3
page Profil amélioré + back office
· ef140c06
Ramzi BENMANSOUR
authored
May 05, 2023
ef140c06
Show whitespace changes
Inline
Side-by-side
src/main/java/fr/ldnr/servelets/Profile.java
0 → 100644
View file @
ef140c06
/*
* 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
fr.ldnr.servelets
;
import
java.io.IOException
;
import
java.io.PrintWriter
;
import
javax.servlet.ServletException
;
import
javax.servlet.annotation.WebServlet
;
import
javax.servlet.http.HttpServlet
;
import
javax.servlet.http.HttpServletRequest
;
import
javax.servlet.http.HttpServletResponse
;
/**
*
* @author stag
*/
@WebServlet
(
name
=
"Profile"
,
urlPatterns
=
{
"/profile"
})
public
class
Profile
extends
HttpServlet
{
// <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
{
//verifier que user est connecté
if
(
request
.
getSession
().
getAttribute
(
"user"
)
!=
null
)
{
request
.
getRequestDispatcher
(
"/WEB-INF/Profile.jsp"
)
.
forward
(
request
,
response
);
}
else
{
response
.
sendRedirect
(
request
.
getContextPath
()
+
"/login"
);
}
}
/**
* 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
{
}
}
src/main/webapp/WEB-INF/Profile.jsp
0 → 100644
View file @
ef140c06
<%--
Document : Profile
Created on : 5 mai 2023, 03:35:35
Author : stag
--%>
<%@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>
<style>
table
{
border-collapse
:
collapse
;
margin
:
20px
;
width
:
80%
;
border-style
:
none
;
}
td
,
th
{
padding
:
8px
;
text-align
:
left
;
}
th
{
background-color
:
#f2f2f2
;
font-weight
:
bold
;
}
#password-col
{
display
:
none
;
}
/* Style the show password button */
#show-password-btn
{
margin-top
:
10px
;
padding
:
5px
10px
;
background-color
:
#4CAF50
;
color
:
#fff
;
cursor
:
pointer
;
}
</style>
</head>
<body>
<%@include
file=
"/WEB-INF/jspf/Header.jsp"
%>
<h1>
Vos informations personnelles
</h1>
<table>
<tr>
<td>
Votre id :
</td>
<td>
${sessionScope.user.id}
</td>
</tr>
<tr>
<td>
Votre Pseudo :
</td>
<td>
${sessionScope.user.pseudo}
</td>
</tr>
<tr>
<td>
Votre adresse mail :
</td>
<td>
${sessionScope.user.email}
</td>
</tr>
<tr
id=
"password-row"
>
<td>
Votre mot de passe :
</td>
<td
id=
"password-col"
>
${sessionScope.user.password}
</td>
</tr>
</table>
<button
id=
"show-password-btn"
onclick=
"showPassword()"
>
Afficher le mot de passe
</button>
<%@include
file=
"./jspf/Footer.jsp"
%>
<script>
function
showPassword
()
{
var
passwordCol
=
document
.
getElementById
(
"
password-col
"
);
var
showPasswordBtn
=
document
.
getElementById
(
"
show-password-btn
"
);
// Toggle the display of the password column
if
(
passwordCol
.
style
.
display
===
"
none
"
)
{
passwordCol
.
style
.
display
=
"
table-cell
"
;
showPasswordBtn
.
textContent
=
"
Cacher le mot de passe
"
;
}
else
{
passwordCol
.
style
.
display
=
"
none
"
;
showPasswordBtn
.
textContent
=
"
Afficher le mot de passe
"
;
}
}
</script>
</body>
</html>
src/main/webapp/WEB-INF/jspf/Header.jsp
View file @
ef140c06
...
...
@@ -49,9 +49,16 @@
<nav>
<ul>
<li><a
href=
"
<c:url
value=
'/home'
/>
"
>
Home
</a></li>
<c:choose>
<c:when
test=
"
${
empty
sessionScope
.
user
}
"
>
<li><a
href=
"
<c:url
value=
'/sign-in'
/>
"
>
Inscription
</a></li>
<li><a
href=
"
<c:url
value=
'/login'
/>
"
>
Connexion
</a></li>
<li><a
href=
"
<c:url
value=
'/logout'
/>
"
>
Se deconnecter
</a></li>
</c:when>
<c:otherwise>
<li><a
href=
"
<c:url
value=
'/createArticle'
/>
"
>
Créer un article
</a></li>
<li><a
href=
"
<c:url
value=
'/logout'
/>
"
>
Se deconnecter
</a></li>
<li><a
href=
"
<c:url
value=
'/profile'
/>
"
>
Mon compte
</a></li>
</c:otherwise>
</c:choose>
</ul>
</nav>