Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
SAE4.A02.1
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Maxime Gosselin
SAE4.A02.1
Commits
98d5867d
Commit
98d5867d
authored
2 months ago
by
Maxime Gosselin
Browse files
Options
Downloads
Patches
Plain Diff
Envoie des messages fonctionnels
parent
3a5041b2
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
WEB-INF/src/controleur/MessageController.java
+42
-0
42 additions, 0 deletions
WEB-INF/src/controleur/MessageController.java
WEB-INF/vue/chat.jsp
+3
-3
3 additions, 3 deletions
WEB-INF/vue/chat.jsp
with
45 additions
and
3 deletions
WEB-INF/src/controleur/MessageController.java
0 → 100644
+
42
−
0
View file @
98d5867d
package
controleur
;
import
jakarta.servlet.ServletException
;
import
jakarta.servlet.annotation.WebServlet
;
import
jakarta.servlet.http.HttpServlet
;
import
jakarta.servlet.http.HttpServletRequest
;
import
jakarta.servlet.http.HttpServletResponse
;
import
modele.dao.DaoMessage
;
import
modele.dto.Message
;
import
java.io.IOException
;
import
java.time.LocalDateTime
;
@WebServlet
(
"/message"
)
public
class
MessageController
extends
HttpServlet
{
@Override
protected
void
service
(
HttpServletRequest
req
,
HttpServletResponse
resp
)
throws
ServletException
,
IOException
{
String
username
;
// vérification de l'authentification
if
((
username
=
(
String
)
req
.
getSession
().
getAttribute
(
"username"
))
==
null
){
resp
.
sendRedirect
(
"index.html"
);
return
;
}
String
action
=
(
String
)
req
.
getParameter
(
"action"
);
String
vue
;
switch
(
action
){
case
"send"
:
String
contenue
=
req
.
getParameter
(
"message"
);
DaoMessage
daoMessage
=
new
DaoMessage
();
int
idThread
=
Integer
.
parseInt
(
req
.
getParameter
(
"thread"
));
Message
message
=
new
Message
(
0
,
username
,
idThread
,
contenue
,
LocalDateTime
.
now
());
daoMessage
.
create
(
message
);
vue
=
"thread?action=open&id="
+
idThread
;
break
;
default
:
vue
=
""
;
}
req
.
getRequestDispatcher
(
vue
).
forward
(
req
,
resp
);
}
}
This diff is collapsed.
Click to expand it.
WEB-INF/vue/chat.jsp
+
3
−
3
View file @
98d5867d
...
@@ -106,12 +106,12 @@
...
@@ -106,12 +106,12 @@
<%
}
}
%>
<%
}
}
%>
<div
id=
"input"
class=
"fixed-bottom p-2 bg-white border-top border-2 border-dark"
>
<div
id=
"input"
class=
"fixed-bottom p-2 bg-white border-top border-2 border-dark"
>
<form
class=
"input-group mb-3 container-lg"
method=
"post"
action=
"
#
"
>
<form
class=
"input-group mb-3 container-lg"
method=
"post"
action=
"
message?action=send&thread=
<%=
id
%>
"
>
<a
class=
"input-group-text link-primary"
href=
"
chat.html
"
>
<a
class=
"input-group-text link-primary"
href=
"
thread?action=open&id=
<%=
id
%>
"
>
<i
class=
"bi-arrow-clockwise"
></i>
<i
class=
"bi-arrow-clockwise"
></i>
</a>
</a>
<textarea
name=
"message"
class=
"form-control"
placeholder=
"Entrez votre message ici."
></textarea>
<textarea
name=
"message"
class=
"form-control"
placeholder=
"Entrez votre message ici."
></textarea>
<input
type=
"submit"
class=
"input-group-text"
>
<input
type=
"submit"
class=
"input-group-text"
value=
"Envoyer"
>
</form>
</form>
</div>
</div>
</div>
</div>
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment