Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
S
S4.A02.1-H-Adrien.fryson-Othemane.khachnane
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
Othemane Khachnane
S4.A02.1-H-Adrien.fryson-Othemane.khachnane
Commits
b779288c
Commit
b779288c
authored
2 months ago
by
Othemane KHACHNANE
Browse files
Options
Downloads
Patches
Plain Diff
CreateNewFil servlet
parent
70c9390a
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
sae/WEB-INF/src/controleur/CreateNewFil.java
+39
-0
39 additions, 0 deletions
sae/WEB-INF/src/controleur/CreateNewFil.java
sae/WEB-INF/vue/CreationFils.jsp
+17
-0
17 additions, 0 deletions
sae/WEB-INF/vue/CreationFils.jsp
with
56 additions
and
0 deletions
sae/WEB-INF/src/controleur/CreateNewFil.java
0 → 100644
+
39
−
0
View file @
b779288c
package
controleur
;
import
java.io.IOException
;
import
java.io.PrintWriter
;
import
java.nio.file.Files
;
import
java.nio.file.Paths
;
import
java.sql.*
;
import
java.nio.charset.StandardCharsets
;
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.DS
;
@WebServlet
(
"/CreateNewFil"
)
public
class
CreateNewFil
extends
HttpServlet
{
public
void
service
(
HttpServletRequest
req
,
HttpServletResponse
res
)
{
try
{
String
nom
=
req
.
getParameter
(
"nom"
);
int
createur_id
=
Integer
.
parseInt
(
req
.
getParameter
(
"createur_id"
));
String
query
=
"INSERT INTO FilDeDiscussion (nom, createur_id) VALUES (?, ?)"
;
Connection
con
=
DS
.
getConnection
();
PreparedStatement
pstmt
=
con
.
prepareStatement
(
query
);
pstmt
.
setString
(
1
,
nom
);
pstmt
.
setInt
(
2
,
createur_id
);
System
.
out
.
println
(
pstmt
);
int
n
=
pstmt
.
executeUpdate
();
System
.
out
.
println
(
n
);
req
.
getRequestDispatcher
(
"CreationFils.jsp"
).
forward
(
req
,
res
);
con
.
close
();
}
catch
(
Exception
e
)
{
//e.printStackTrace();
System
.
out
.
println
(
e
.
getMessage
());
}
}
}
This diff is collapsed.
Click to expand it.
sae/WEB-INF/vue/CreationFils.jsp
0 → 100644
+
17
−
0
View file @
b779288c
<%@ page
contentType=
"text/html;charset=UTF-8"
language=
"java"
%>
<!DOCTYPE html>
<html>
<head>
<title>
Liste des Fils
</title>
</head>
<body>
<h1>
Créer un nouveau fil de discussion
</h1>
<form
action=
"CreateNewFil"
method=
"post"
>
<label
for=
"nom"
>
Nom du fil:
</label>
<input
type=
"text"
id=
"nom"
name=
"nom"
required
><br><br>
<label
for=
"createur_id"
>
ID du créateur:
</label>
<input
type=
"number"
id=
"createur_id"
name=
"createur_id"
><br><br>
<input
type=
"submit"
value=
"Créer"
>
</form>
</body>
</html>
\ No newline at end of file
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