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 :

Classe de connexion introuvable


Sujet :

Servlets/JSP Java

  1. #1
    Membre actif
    Inscrit en
    Juin 2005
    Messages
    578
    Détails du profil
    Informations forums :
    Inscription : Juin 2005
    Messages : 578
    Points : 240
    Points
    240
    Par défaut Classe de connexion introuvable
    bonjour
    J'ai une page "index.jsp" qui contient un champ "login",un champ "mot de passe" et un bouton "Connexion".
    Voici le code de "index.jsp":

    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
    72
    73
    74
    75
    76
    77
    78
    79
    80
    81
    82
    83
    84
    85
    86
    87
    88
    89
    90
    91
    92
    93
    94
    95
    96
    97
    98
    99
    100
    101
    102
    103
    104
    105
    106
    107
    108
    109
    110
    111
    112
    113
    114
    115
    116
    117
    118
    119
    120
    121
    122
    123
    124
    125
    126
    127
    128
    129
    130
    131
    132
    133
    134
    135
    136
    137
    138
    139
    140
    141
    142
    143
    144
    145
    146
    147
    148
    149
    150
    151
    152
    153
    154
    155
    156
    157
    158
    159
    160
    161
    162
    163
    164
    165
    166
    167
    168
    169
    170
    171
    172
    173
    174
    175
    176
    177
    178
    179
    180
    181
    182
    183
    184
    185
    186
    187
    188
    189
    190
    191
    192
    193
    194
    195
    196
    197
    198
    199
    200
    201
    202
    203
    204
    205
    206
    207
    208
    209
    210
    211
    212
    213
    214
    215
    216
    217
    218
    219
    220
    221
    222
    223
    224
    225
    226
    227
    228
    229
    230
    231
    232
    233
    234
    235
    236
    237
    238
    239
    240
     
    <%--
        Document   : index
        Created on : 8 févr. 2012, 11:17:22
        Author     : Moussa-Virtuel
    --%>
     
    <%@ page contentType="text/html; charset=utf-8" language="java" import="java.sql.*,tetris.*" errorPage="" %>
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
    <title>index</title>
     
    <style type="text/css">
            A:visited {color:#D78E37;}
            A:link {color:#D78E37;}
            .fontw {color:#FFFFFF;font-size:10px;font-family:arial;text-decoration:none;}
            .fontb {color:#867766;font-size:10px;font-family:arial;text-decoration:none;}
            .fontb2 {color:#4A3114;font-size:10px;font-family:arial;text-decoration:none;}
            BODY {margin-left: 0pt}
            BODY {margin-right: 0pt}
            BODY {margin-top: 0pt}
            BODY {margin-bottom: 0pt}
            .navbar a:link {color: #FFFFFF;font-size:10px;font-family:arial;line-height : 16px}
            .navbar a:visited {color: #FFFFFF;font-size:10px;font-family:arial;line-height : 16px}
    </style>
    <script type="text/javascript">
     
    </script>
    <script src="Scripts/AC_RunActiveContent.js" type="text/javascript"></script>
    </head>
    <%
    HttpSession sessio =request.getSession(true);
     
    User u;
    u = (User)sessio.getAttribute("User");
    %>
    <body bgcolor="#EFEBE6">
     
     
    <center>
     
    <table cellpadding="0" cellspacing="0" border="0" width="760"><tr><td width="230" valign="top">
     
    <table cellpadding="0" cellspacing="0" border="0">
      <tr>
        <td>&nbsp;</td>
      </tr>
      <tr><td>
    <img src="Pages/images/spacer.gif" height="1"></td>
    </tr><tr><td>
    <a href=""><img src="Pages/menu/1.gif" border="0"></a></td>
    </tr><tr><td>
    <a href=""><img src="Pages/menu/2.gif" border="0"></a></td>
    </tr><tr><td>
    <a href=""><img src="Pages/menu/3.gif" border="0"></a></td>
    </tr><tr><td>
    <a href=""><img src="Pages/menu/4.gif" border="0"></a></td>
    </tr><tr><td>
    <a href=""><img src="Pages/menu/5.gif" border="0"></a></td>
    </tr><tr><td>
    <a href=""><img src="Pages/menu/6.gif" border="0"></a></td>
    </tr><tr><td height="29"><a href=""><img src="Pages/menu/7.gif" border="0"></a></td>
    </tr><tr><td>
    <img src="Pages/images/searchp.gif"></td>
    </tr><tr><td bgcolor="#EFA751" height="173" align="center">
     
    <table class="fontb2"><tr><td>
    What city:</td><td>
    <input type="text" size="14">
    </td></tr><tr><td>
    What state:</td><td>
    <select><option value='0'>Select state</option></select>
    </td></tr><tr><td>
    Zip code:</td><td>
    <input type="text" size="10">
    </td></tr><tr><td>
    Search area</td><td>
    <select><option value='0'>Select search radius</option></select>
    </td></tr><tr><td>
    Price range</td><td>
     
    <table cellpadding="0" cellspacing="0" border="0"><tr><td>
    <select><option value='0'>All prices</option></select>
    </td><td width="4"></td><td>
    <select><option value='0'>All</option></select>
    </td></tr></table>
     
    </td></tr><tr><td>&nbsp;
    </td><td align="right" height="26">
    <a href=""><img src="Pages/images/search.gif" border="0"></a></td>
    </tr></table>
     
    </td></tr><tr><td>
    <img src="Pages/images/latest.gif"></td>
    </tr><tr><td bgcolor="#906140" height="153" align="center">
     
    <table class="fontw" width="200"><tr><td>
    Aenean non arcu. Quisque accumsan faucibus justo. Nunc aliquet vestibulum dui. Mauris in augue. In hac habitasse platea dictumst.</td></tr></table>
     
    <table class="fontw" width="200"><tr><td>
    <a href=""><img src="Pages/images/1.gif" border="0"></a></td>
    <td>
    <a href=""><img src="Pages/images/2.gif" border="0"></a></td>
    </tr></table>
     
    </td></tr><tr><td>
    <a href=""><img src="Pages/images/details.gif" border="0"></a></td>
    </tr></table>
     
    </td><td valign="top">
     
    <table cellpadding="0" cellspacing="0" border="0"><tr><td width="221">
    <img src="Pages/images/htop.gif"></td>
    <td width="419">
    <a href=""><img src="Pages/images/logo.gif" width="419" height="101" border="0"></a></td>
    </tr></table>
     
    <table cellpadding="0" cellspacing="0" border="0"><tr><td>
    <img src="Pages/images/header.gif"></td>
    <td valign="top">
     
    <table width="272" border="0" cellpadding="0" cellspacing="0">
      <tr><td>
    <img src="Pages/images/mlogin.gif" width="272" height="28"></td>
    </tr><tr><td width="184" height="82" background="Pages/images/mbg.gif" align="center">
     
     
      <table width="200" border="1">
      <form id="form1" name="form1" method="post" action="Connecter">
        <tr>
          <td>Login:</td>
          <td><label>
            <input type="login" name="textfield" id="textfield" />
          </label></td>
        </tr>
        <tr>
          <td>Password:</td>
          <td><label>
            <input type="passwd" name="textfield2" id="textfield2" />
          </label></td>
        </tr>
        <tr>
          <td>&nbsp;</td>
          <td><label>
            <input type="submit" name="button" id="button" value="Connexion" />
          </label></td>
        </tr>
        </form>
      </table>
    </td>
    </tr><tr><td>&nbsp;</td>
    </tr></table>
    </td></tr>
     
    </table>
     
    <table cellpadding="0" cellspacing="0" border="0" width="640" height="217" bgcolor="#FFFFFF">
      <tr>
        <td align="center"><table class="fontb" width="480">
          <tr>
            <td><b><font style="font-size:12px;" color="#D78E37">Welcome to our real estate company!</font></b><br>
              Aenean non arcu. Quisque accumsan faucibus justo. Nunc aliquet vestibulum dui. Mauris in augue. In hac habitasse platea dictumst. Vestibulum ut mi eget sem nonummy blandit. Etiam magna augue, posuere laoreet, pellentesque non, cursus et, sem. Donec a urna. Morbi ac arcu id purus posuere iaculis. Integer malesuada aliquam magna. Pellentesque porta tempor augue. Aenean sed ligula a justo elementum rhoncus. <a href="">Read more.</a> </td>
          </tr>
        </table>
        </td>
      </tr>
      <tr><td width="530" align="center">
     
    <br>
    <table class="fontb" width="497">
      <tr><td width="109">
        <a href="Pages/galerie.jsp"><img src="Pages/images/home.gif" width="129"></a></td>
    <td width="5"></td><td width="360">
    <b><font style="font-size:12px;" color="#D78E37">Great opportunities for investors!</font></b><br>
    Aenean non arcu. Quisque accumsan faucibus justo. Nunc aliquet vestibulum dui. Mauris in augue. In hac habitasse platea dictumst. Vestibulum ut mi eget sem nonummy blandit. Etiam magna augue, posuere laoreet, pellentesque non, cursus et, sem. <a href="">Read more.</a>
    </td></tr></table>
     
    <br>
    <table class="fontb" width="500">
      <tr><td width="125">
    <img src="Pages/images/home.gif" width="130"></td>
    <td width="5"></td><td width="343">
    <b><font style="font-size:12px;" color="#D78E37">Great opportunities for investors!</font></b><br>
    Aenean non arcu. Quisque accumsan faucibus justo. Nunc aliquet vestibulum dui. Mauris in augue. In hac habitasse platea dictumst. Vestibulum ut mi eget sem nonummy blandit. Etiam magna augue, posuere laoreet, pellentesque non, cursus et, sem. <a href="">Read more.</a>
    </td></tr></table>
     
    <br>
    <table class="fontb" width="499">
      <tr><td>
    <img src="Pages/images/home.gif" width="128"></td>
    <td width="5"></td><td>
    <b><font style="font-size:12px;" color="#D78E37">Great opportunities for investors!</font></b><br>
    Aenean non arcu. Quisque accumsan faucibus justo. Nunc aliquet vestibulum dui. Mauris in augue. In hac habitasse platea dictumst. Vestibulum ut mi eget sem nonummy blandit. Etiam magna augue, posuere laoreet, pellentesque non, cursus et, sem. <a href="">Read more.</a>
    </td></tr></table>
     
    <br>
     
     
    </td></tr></table>
     
     
     
     
    <table cellpadding="0" cellspacing="0" border="0" height="36" width="515" background="bbg.gif"><tr><td class="fontb" align="right">
    <a href="">Home</a>
    |
    <a href="">Company</a>
    |
    <a href="">Products</a>
    |
    <a href="">Downloads</a>
    |
    <a href="">Store</a>
    &nbsp;&nbsp;
    </td></tr></table>
    </td></tr></table>
     
    </center>
    <div align="center">dffffdfsff<br>
     
     
      <!-- Start of StatCounter Code -->
      <script type="text/javascript">
    var sc_project=2962046;
    var sc_invisible=0;
    var sc_partition=32;
    var sc_security="b2bb6276";
      </script>
     
      <script type="text/javascript" src="http://www.statcounter.com/counter/counter_xhtml.js"></script>
      <noscript>
      <div class="statcounter"><a class="statcounter" href="http://www.statcounter.com/"><img class="statcounter" src="http://c33.statcounter.com/2962046/0/b2bb6276/0/" alt="statistics" /></a></div>
      <a href="http://aztemplates.com/" style="font-size: 18px; color: #555555;"><strong>nightclub website templates</strong></a> <a href="http://getfreetemplates.com/" style="font-size: 18px; color: #800000;"><b>dreamweaver ecommerce templates</b></a> <a href="http://diablotemplates.com/" style="font-size: 14px; color: #555555;"><u>religious web templates</u></a> <a href="http://allfreetemplates.info/" style="font-size: 21px; color: #666666;"><i>website flash templates</i></a>
      </noscript>
      <!-- End of StatCounter Code -->
    </div>
    </body>
    </html>


    Quand je clique sur "Connexion",il y'a une classe "Connecter.java" qui doit être invoquée pour permettre la connexion.
    voici la classe "Connecter.java":

    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
    72
    73
    74
    75
    76
    77
    78
    79
    80
    81
    82
    83
    84
    85
    86
    87
    88
    89
    90
    91
    92
    93
    94
    95
    96
    97
    98
    99
    100
    101
    102
    103
     
    /*
     * To change this template, choose Tools | Templates
     * and open the template in the editor.
     */
     
    package tetris;
     
    import java.io.IOException;
    import java.io.PrintWriter;
    import javax.servlet.ServletException;
    //import javax.servlet.annotation.WebServlet;
    import javax.servlet.http.HttpServlet;
    import javax.servlet.http.HttpServletRequest;
    import javax.servlet.http.HttpServletResponse;
    import javax.servlet.*;
    import java.io.*;
    import javax.servlet.http.*;
    import java.sql.*;
    import tetris.Connecter;
    import tetris.User;
     
    /**
     *
     * @author Mo
     */
    //@WebServlet(name="Connexion", urlPatterns={"/Connexion"})
    public class Connecter extends HttpServlet {
     
    PrintWriter sortie;
    RequestDispatcher d;
    Connecter con;
    PreparedStatement pst;
    ResultSet resultat;
    User u;
    public void doGet(HttpServletRequest requete, HttpServletResponse reponse)throws ServletException , IOException
     {
      doPost(requete , reponse);
     }
     
     
    public void doPost(HttpServletRequest req, HttpServletResponse rep) throws ServletException , IOException
     {
     
      try
     
        {
    sortie = rep.getWriter();
    rep.setContentType("text/html");
     
         String log=req.getParameter("login");
         String pass=req.getParameter("passwd");
     
         Class.forName("com.mysql.jdbc.Driver");
     
         con =  (Connecter) DriverManager.getConnection("jdbc:mysql://localhost:3306/dbTetris","root","passer");
     
      pst=con.prepareStatement("select * from user where login=? && password=? ");
      pst.setString(1,log);
      pst.setString(2,pass);
      resultat =pst.executeQuery() ;
     boolean connecte =false;
      if (resultat.next())
        {    connecte=true;
     
              u = new User();
     
                    u.setId_P(Integer.parseInt(resultat.getString("id_user")));
                    u.setLogin(resultat.getString("login"));
                    u.setPassword(resultat.getString("password"));
                    u.setNom(resultat.getString("nom"));
                    u.setPrenom(resultat.getString("prenom"));
                    u.setAdresse(resultat.getString("adresse"));
                    u.setFonction(resultat.getInt("fonction"));
     
                    HttpSession ma_session =req.getSession(true);
                    ma_session.setAttribute("User",u);
                    d=req.getRequestDispatcher("index.jsp");
                    d.forward(req,rep);
     
      }
     else{
                      d=req.getRequestDispatcher("erreurConnexion.jsp");
                      d.forward(req,rep);
                 }
    }
       catch (ClassNotFoundException e ) {sortie.println("impossible de charger le pilote") ; }
      catch (SQLException se) { sortie.println(""+se.getMessage()) ;}
     
    }  /**
         * Returns a short description of the servlet.
         * @return a String containing servlet description
         */
        @Override
        public String getServletInfo() {
            return "Short description";
        }// </editor-fold>
     
        private PreparedStatement prepareStatement(String string) {
            throw new UnsupportedOperationException("Not yet implemented");
        }
     
    }
    Mais j'ai un message d'erreur qui dit:

    HTTP Status 404 -

    type Status report

    message

    descriptionThe requested resource () is not available.
    GlassFish v3
    Apparemment la classe Connecter.java est introuvable.

    Merci

  2. #2
    Membre du Club
    Profil pro
    Inscrit en
    Décembre 2008
    Messages
    84
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Décembre 2008
    Messages : 84
    Points : 65
    Points
    65
    Par défaut
    Le web.xml?

  3. #3
    Expert éminent sénior
    Avatar de tchize_
    Homme Profil pro
    Ingénieur développement logiciels
    Inscrit en
    Avril 2007
    Messages
    25 482
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 45
    Localisation : Belgique

    Informations professionnelles :
    Activité : Ingénieur développement logiciels
    Secteur : High Tech - Éditeur de logiciels

    Informations forums :
    Inscription : Avril 2007
    Messages : 25 482
    Points : 48 804
    Points
    48 804
    Par défaut
    1) ton annotation WebServlet est commentée -> elle ne sera jamais lue. Décommente la
    2) tu mappe sur /Connexion mais dans ton formulaire tu vise /Connecter, ce n'est pas la même chose.

  4. #4
    Membre actif
    Inscrit en
    Juin 2005
    Messages
    578
    Détails du profil
    Informations forums :
    Inscription : Juin 2005
    Messages : 578
    Points : 240
    Points
    240
    Par défaut
    Ok merci beaucoup,ça marcheeeeeeeee

+ Répondre à la discussion
Cette discussion est résolue.

Discussions similaires

  1. [Cookies] Classe de connexion à l'admin
    Par gtraxx dans le forum Langage
    Réponses: 17
    Dernier message: 23/01/2008, 23h41
  2. [POO] Classe de connexion à une base de données
    Par iwf-fr dans le forum Langage
    Réponses: 3
    Dernier message: 13/11/2007, 13h55
  3. pb de creation de classe de connexion
    Par oceane751 dans le forum JDBC
    Réponses: 2
    Dernier message: 30/07/2007, 15h37
  4. [MySQL] Classe database + connexion multiple + principe mal compris
    Par Rodrigue dans le forum PHP & Base de données
    Réponses: 3
    Dernier message: 14/08/2006, 14h06
  5. Petit souci JSP et class de connexion a BdD
    Par LeXo dans le forum Servlets/JSP
    Réponses: 13
    Dernier message: 07/06/2006, 00h57

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