1 pièce(s) jointe(s)
JSP ne trouve pas ma servlet
Bonsoir,
C'est grace à vous que je commence à programmer, mais une fois de plus j'ai un message d'erreur Etat HTTP 404 -/monduproject/Login
Voici mon fichier login.jsp
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
| <body>
<div align="center"><font size="5" face="Verdana, Arial, Helvetica, sans-serif">Gestion.</font></div>
<div>
<form action="Login" method="post">
<fieldset style="width:850px; margin-right:auto; margin-left:auto" style="width:400px"><legend style="font-weight:700;"><span class="style1"><em>Identification des utilisateurs</em></span></legend>
<p align="center"><label for="login"> Matricule : </label>
<input type="text" name="login" value=""/></p>
<p align="center"><label for="password_user">Password :</label>
<input type="password" name="password" value=""/></p>
<p align="center"><label for="choix">Module :</label>
<select>
<option value="AUTRES">Autres modules</option>
<option value="MOSUC">Suivi</option>
</select></p>
<p align="center"><input type="submit" name="submit" value="Connexion" /></p>
</fieldset>
</form>
</div>
</body> |
et voici le contenu du fichier Login.java
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59
| package servletPackage;
import java.io.IOException;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
import classMetier.*;
import daoPackage.*;
@SuppressWarnings("serial")
public class Login extends HttpServlet {
public static final String ATT_MESSAGE = "message";
//public static final String VUE ="/WebContent/login.jsp";
@Override
protected void doGet(HttpServletRequest req, HttpServletResponse resp)
throws ServletException, IOException {
HttpSession session=req.getSession();
session.removeAttribute("user");
session.invalidate();
this.getServletContext().getRequestDispatcher(VUE).forward(req, resp);
}
@Override
protected void doPost(HttpServletRequest req, HttpServletResponse resp)
throws ServletException, IOException {
// TODO Auto-generated method stub
String log=req.getParameter("log");
String pwd=req.getParameter("pwd");
if (log.isEmpty() || pwd.isEmpty()){
String erreur ="Login ou mot de passe incorrect !";
req.setAttribute("log", erreur);
this.getServletContext().getRequestDispatcher("VUE").forward(req, resp);
}
else {
Utilisateur user=new Utilisateur(log, pwd);
DaoUser daouser =new DaoUser();
int rep=daouser.SelectUser(user);
if (rep==1){
HttpSession session=req.getSession(true);
session.setAttribute("user", user);
DaoUser.codeuser=user.getLogin();
System.out.println("Utilisateur:"+ session.getAttribute(log));
resp.sendRedirect("acceuil_mosuc.jsp");
}
else {
String erreur ="Utilisateur non autorisé !";
req.setAttribute("log", erreur);
//this.getServletContext().getRequestDispatcher(VUE).forward(req, resp);
}
}
}
} |
et le fichier web.xml
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13
| <display-name>cm.acep-cameroun</display-name>
<welcome-file-list>
<welcome-file>login.jsp</welcome-file>
</welcome-file-list>
<servlet>
<servlet-name>Login</servlet-name>
<servlet-class>servletPackage.Login</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>Login</servlet-name>
<url-pattern>/connexion</url-pattern>
</servlet-mapping> |
merci de votre aide