correction bug, finalisation des servlet
This commit is contained in:
@@ -15,12 +15,10 @@ public class SessionDAO extends AbstractJpaDao<Integer, Session> {
|
||||
}
|
||||
|
||||
public List<Session> findByTheme(String theme){
|
||||
EntityTransaction t=em.getTransaction();
|
||||
t.begin();
|
||||
Query query=em.createQuery("select s from Session s where s.theme=:theme");
|
||||
query.setParameter("theme",theme);
|
||||
List<Session> sessions=query.getResultList();
|
||||
t.commit();
|
||||
|
||||
if(sessions.size()>0){
|
||||
return sessions;
|
||||
}else{
|
||||
@@ -40,6 +38,5 @@ public class SessionDAO extends AbstractJpaDao<Integer, Session> {
|
||||
s.getQuizzs().add(q);
|
||||
em.merge(s);
|
||||
t.commit();
|
||||
em.refresh(s);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -10,4 +10,5 @@ public class UtilisateurDTO {
|
||||
private int id;
|
||||
private String name;
|
||||
private String email;
|
||||
private String password;
|
||||
}
|
||||
|
||||
@@ -82,7 +82,7 @@ public class QuestionInfo extends HttpServlet {
|
||||
|
||||
resp.getWriter().println(
|
||||
"<HTML>\n<BODY>\n" +
|
||||
"<H1> Success </H1>" +
|
||||
"<H1> Question \"" + question.getQuestion() + "\" creee </H1>" +
|
||||
"</BODY></HTML>"
|
||||
);
|
||||
return ;
|
||||
|
||||
@@ -29,7 +29,6 @@ public class QuizzInfo extends HttpServlet {
|
||||
UtilisateurDAO uDAO = new UtilisateurDAO();
|
||||
String email_user = req.getParameter("email_User");
|
||||
String id_User = req.getParameter("id_User");
|
||||
// String id_session = req.getParameter("code_pin");
|
||||
|
||||
Utilisateur u_cree_quizz = null;
|
||||
|
||||
@@ -50,5 +49,10 @@ public class QuizzInfo extends HttpServlet {
|
||||
quizz.setUtilisateur(u_cree_quizz);
|
||||
//quizz.setSession(s_attached);
|
||||
quizzDAO.create(quizz);
|
||||
|
||||
resp.getWriter().println("<HTML>\n<BODY>\n" +
|
||||
"<H1>Quizz cree par " + u_cree_quizz.getName() + "</H1>" +
|
||||
"</BODY></HTML>");
|
||||
return ;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -54,7 +54,7 @@ public class SessionInfo extends HttpServlet {
|
||||
sessionDAO.addQuizz(quizz,session);
|
||||
|
||||
|
||||
resp.getWriter().println("<h1>Quizz"+ idQuizz +" et ajouté à la session " + sessionID + " !</h1>");
|
||||
resp.getWriter().println("<h1>Quizz"+ idQuizz +" est ajouté à la session " + sessionID + " !</h1>");
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -47,7 +47,7 @@ public class Show extends HttpServlet {
|
||||
"<table class=\"show\">" +
|
||||
"<thead class=\"show\">" +
|
||||
"<tr>" +
|
||||
"<th class=\"show\">Nom</th><th class=\"show\">mail</th>" +
|
||||
"<th class=\"Id\">Nom</th><th class=\"show\">Nom</th><th class=\"show\">mail</th><th class=\"show\">Password</th>" +
|
||||
"</tr>" +
|
||||
"</thead>" +
|
||||
"<tbody>";
|
||||
@@ -55,8 +55,8 @@ public class Show extends HttpServlet {
|
||||
UtilisateurDTO dto = mapper_u.toDTO(u);
|
||||
result +=
|
||||
"<tr>" +
|
||||
"<th class=\"show\">" + dto.getName() + "</th>" + "<th class=\"show\">" + dto.getEmail() + "</th>" +
|
||||
"</tr>";
|
||||
"<th class=\"show\">" + dto.getId() + "</th><th class=\"show\">" + dto.getName() + "</th><th class=\"show\">" + dto.getEmail() + "</th><th class=\"show\">" + dto.getPassword() + "</th>"+
|
||||
"</tr>";
|
||||
System.out.println(u.getName()+dto.getEmail());
|
||||
}
|
||||
result +=
|
||||
|
||||
@@ -30,11 +30,13 @@ public class UserInfo extends HttpServlet {
|
||||
Utilisateur u = new Utilisateur();
|
||||
u.setName(request.getParameter("name"));
|
||||
u.setEmail(request.getParameter("email"));
|
||||
u.setPassword(request.getParameter("password"));
|
||||
|
||||
|
||||
utilisateurDAO.create(u);
|
||||
PrintWriter out = response.getWriter();
|
||||
out.println("<HTML>\n<BODY>\n" +
|
||||
"<H1>Recapitulatif des informations de Tibo</H1>\n" +
|
||||
"<H1>Recapitulatif des informations de l'utilisateur</H1>\n" +
|
||||
"<UL>\n" + " <LI>Nom: " + request.getParameter("name") +
|
||||
"\n" + " <LI>Email: " + request.getParameter("email") + "\n" +
|
||||
"</BODY></HTML>");
|
||||
@@ -43,7 +45,7 @@ public class UserInfo extends HttpServlet {
|
||||
int userId = Integer.parseInt(request.getParameter("userId"));
|
||||
utilisateurDAO.addToSession(sessionId, userId);
|
||||
response.getWriter().println("<h1> Reussi d'ajouter utilisateur " +
|
||||
userId + " au session " + sessionId + "</h1>");
|
||||
userId + " à la session " + sessionId + "</h1>");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,20 +3,26 @@
|
||||
<html lang="en">
|
||||
<body>
|
||||
<h1>Creer une session</h1>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<form action="SessionInfo" method="POST">
|
||||
<input type="hidden" name="action" value="createSession">
|
||||
Theme: <input type="text" name="theme">
|
||||
CodePin <input type="number" name="codePIN">
|
||||
<input type="submit" value="Creer Session">
|
||||
</form>
|
||||
Theme: <input type="text" name="theme"><br/>
|
||||
CodePin <input type="number" name="codePIN"><br/>
|
||||
<input type="submit" value="createSession">
|
||||
</form>
|
||||
|
||||
<h1>Ajouter un quizz à une session</h1>
|
||||
|
||||
<form action="SessionInfo" method="POST">
|
||||
<input type="hidden" name="action" value="addQuizz">
|
||||
session ID <input type="number" name="sessionID">
|
||||
ID Quizz <input type="number" name="idQuizz">
|
||||
<input type="submit" value="Add Quizz">
|
||||
session ID <input type="number" name="sessionID"><br/>
|
||||
ID Quizz <input type="number" name="idQuizz"><br/>
|
||||
<input type="submit" value="addQuizz">
|
||||
</form>
|
||||
|
||||
|
||||
</body>
|
||||
</html>
|
||||
@@ -1,11 +1,16 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<title>User manager</title>
|
||||
</head>
|
||||
<body>
|
||||
<h1>Creer l'utilisateur</h1>
|
||||
<FORM Method="POST" Action="UserInfo">
|
||||
<input type="hidden" name="action" value="addUser">
|
||||
Name : <INPUT type="text" size="20" name="name"><BR>
|
||||
Email : <INPUT type="text" size="20" name="email"><BR>
|
||||
Passworld : <INPUT type="text" size="20" name="password"><BR>
|
||||
<INPUT type="submit" value="Send">
|
||||
</FORM>
|
||||
|
||||
|
||||
@@ -2,10 +2,10 @@
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<title>Title</title>
|
||||
<title>Kaflop!</title>
|
||||
</head>
|
||||
<body>
|
||||
<h1>Hello World!</h1>
|
||||
<h1>Kaflop!</h1>
|
||||
<a href =http://localhost:8080/UserInfo.html>myform</a>
|
||||
<a href =http://localhost:8080/Session.html>session</a>
|
||||
<a href =http://localhost:8080/Quizz.html>Quizz</a>
|
||||
|
||||
Reference in New Issue
Block a user