IdentifiantMot de passe
Loading...
Mot de passe oublié ?Je m'inscris ! (gratuit)
Navigation

Inscrivez-vous gratuitement
pour pouvoir participer, suivre les réponses en temps réel, voter pour les messages, poser vos propres questions et recevoir la newsletter

Servlets/JSP Java Discussion :

Fonctionner une page html avec une servlet


Sujet :

Servlets/JSP Java

  1. #1
    Membre à l'essai
    Inscrit en
    Mars 2007
    Messages
    20
    Détails du profil
    Informations forums :
    Inscription : Mars 2007
    Messages : 20
    Points : 17
    Points
    17
    Par défaut Fonctionner une page html avec une servlet
    salut à tous,
    je trouve un pb dans le fonctionnement de ma page html avec une servlet.
    voilà le code la page html:

    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>
    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
    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){}
         }
       }
    }
    je réalise le travail avec jbuilder9 et j'ai installé Tomcat4.1
    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..........

  2. #2
    Membre expérimenté Avatar de willoi
    Profil pro
    Développeur informatique
    Inscrit en
    Décembre 2006
    Messages
    1 355
    Détails du profil
    Informations personnelles :
    Âge : 51
    Localisation : France, Haute Garonne (Midi Pyrénées)

    Informations professionnelles :
    Activité : Développeur informatique

    Informations forums :
    Inscription : Décembre 2006
    Messages : 1 355
    Points : 1 639
    Points
    1 639
    Par défaut
    Pour Tomcat, ca se passe comme ca :

    http://mbaron.developpez.com/javaee/tomcat/

    Ensuite si tu as des erreurs, quelles sont-elles ?

Discussions similaires

  1. lecture et integration d'une page xml dans une page html avec JS
    Par bigbrownies dans le forum Général JavaScript
    Réponses: 15
    Dernier message: 29/12/2012, 09h57
  2. Réponses: 6
    Dernier message: 21/08/2012, 23h13
  3. [HTML] Intégrer une page html dans une page html
    Par leloup84 dans le forum Balisage (X)HTML et validation W3C
    Réponses: 3
    Dernier message: 25/03/2008, 12h09
  4. [HTML] Ouvrir une page html avec exel
    Par gedeon555 dans le forum Balisage (X)HTML et validation W3C
    Réponses: 2
    Dernier message: 11/11/2006, 00h08
  5. [vb.net][html] afficher une page html dans une interface vb?
    Par graphicsxp dans le forum Windows Forms
    Réponses: 1
    Dernier message: 29/09/2005, 17h31

Partager

Partager
  • Envoyer la discussion sur Viadeo
  • Envoyer la discussion sur Twitter
  • Envoyer la discussion sur Google
  • Envoyer la discussion sur Facebook
  • Envoyer la discussion sur Digg
  • Envoyer la discussion sur Delicious
  • Envoyer la discussion sur MySpace
  • Envoyer la discussion sur Yahoo