salut à tous,
je trouve un pb dans le fonctionnement de ma page html avec une servlet.
voilà le code la page html:
et le code de la servlet
Code : Sélectionner tout - Visualiser dans une fenêtre à part
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 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <title></title></head> <form method="post" action="http://localhost:8080/enpe/InscriptionEt"> <body> <h2 align="center">Inscription Etudiant</h2> <hr align="center" width="440"> <table width="434" height="245" border="0" align="center"> <tr> <h3><td>Nom</td></h3> <td><input type="text" name="nomin" size="30"></td></tr> <tr> <h3><td>Prénom</td></h3> <td><input type="text" name="pnomin" size="30"></td></tr> <tr> <h3><td>E-mail</td></h3> <td><input type="text" name="melin" size="30"></td></tr> <tr> <h3><td>Diplôme</td></h3> <td><input type="text" name="dipin" size="30"></td></tr> <tr> <h3><td>Groupe</td></h3> <td><input type="text" name="grpin" size="30"></td></tr> <tr> <h3><td>Login</td></h3> <td><input type="text" name="login" size="30"></td></tr> <tr> <h3><td>Mot de Passe</td></h3> <td><input type="text" name="mdpin" size="30"></td></tr> <tr> <h3><td>Confirmation Mot de Passe</td></h3> <td><input type="text" name="cmdpin" size="30"></td></tr> <tr> <td align="right"> <input type="submit" value="S'inscrire"></td><br> <td><input type="reset" value="Réinitialiser"></td></tr> </table> <hr align="center" width="440"/> </body> </html>
je réalise le travail avec jbuilder9 et j'ai installé Tomcat4.1
Code : Sélectionner tout - Visualiser dans une fenêtre à part
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
60
61
62
63
64
65
66
67
68
69
70
71 import javax.servlet.*; import javax.servlet.http.*; import java.io.*; import java.util.*; import java.sql.*; public class InscriptionEt extends HttpServlet { public void doPost(HttpServletRequest req, HttpServletResponse res) throws ServletException, IOException { //les paramètres String nomin = req.getParameter("nomin").trim(); String pnomin = req.getParameter("pnomin").trim(); String melin = req.getParameter("melin").trim(); String dipin = req.getParameter("dipin").trim(); String login = req.getParameter("login").trim(); String mdpin = req.getParameter("mdpin").trim(); boolean proceed = false; if (nomin != null && pnomin != null && melin != null && dipin != null && login != null && mdpin != null) if (nomin.length() > 0 && pnomin.length() > 0 && melin.length() > 0 && dipin.length() > 0 && login.length() > 0 && mdpin.length() > 0) proceed = true; //connexion à la base Connection con = null; PreparedStatement instruction = null; Statement st = null; try { Class.forName("sun.jdbc.odbc.JdbcOdbcDriver"); con = DriverManager.getConnection("jdbc:odbc:enpedb", "", ""); String requete = (""); instruction = con.prepareStatement(requete); st = con.createStatement(); if (proceed) { instruction.setString(1, nomin); instruction.setString(2, pnomin); instruction.setString(3, melin); instruction.setString(4, dipin); instruction.setString(5, login); instruction.setString(6, mdpin); instruction.executeUpdate(); } } catch (ClassNotFoundException e) { throw new ServletException(); } catch (SQLException e) {throw new ServletException();} finally{ try{ if(con !=null)con.close(); if(st !=null)st.close(); if(instruction !=null)instruction.close(); } catch(SQLException e){} } } }
mais je n'ai pas compris comment configurer tomcat.
svp, j'ai besoin d'aide, je suis bloquée dans cette partie
merci d'avance..........
Partager