Bonjour
je suis debutant et depuis plusieur jour je n'arrive pas a faire fonctionner ma servlet jdbc .voici mon .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
 
import java.io.*;
import javax.servlet.*;
import javax.servlet.http.*;
import java.sql.*;
import java.lang.*;
 
public class SupprimerServlet extends HttpServlet{
    public void doGET(HttpServletRequest req,HttpServletResponse res)throws ServletException,IOException {
        String numero=req.getParameter("number");
        res.setContentType("text/plain");
        PrintWriter out=res.getWriter();
 
 
        // Create a variable for the connection string.
            String connectionUrl = "jdbc:odbc:logipro";    
            //integratedSecurity=false;";
        // Declare the JDBC objects.
        Connection con =null;
        ResultSet rs = null;
        CallableStatement cstmt=null;
            try {
                // Establish the connection.
            Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
 
                    con = DriverManager.getConnection(connectionUrl,"admindtz","11admin,");
 
                    // Create and execute an SQL statement that returns some data.
                     String SQL ="{call zdtz_suppression_prospect(numero)}";
                    cstmt=  con.prepareCall (SQL);
                    cstmt.executeUpdate(); 
            //String Sql="select numero From t_prospect";
            //cstmt=  con.prepareCall (SQL);
            //cstmt.execute();
            //if (cstmt.execute()=null){
            //out.Write("<html><head><title>réponse</title></head>"
                //+"<body>Votre requete a été effectuée</body>"
                //+"<p><input type="submit" name="Submit" rows"5" value="supprimé une autre offre"></p>"
 
                    //System.out.println(rs);           
                    // Iterate through the data in the result set and display it.
                //while (rs.next()) {
 
            //    System.out.println(rs.getString());
            //    }
            }
 
        // Handle any errors that may have occurred.
        catch (Exception e) {
            e.printStackTrace();
        }
 
        finally {
            if (rs != null) try { rs.close(); } catch(Exception e) {}
                if (cstmt != null) try { cstmt.close(); } catch(Exception e) {}
                if (con != null) try { con.close(); } catch(Exception e) {}
        }
    }
}
Il fonctionne tres bien quand ce n'est pas une servlet mais une fois que je veux le mettre dans Tomcat c'est finit.
voici mon ifchier 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
 
<html>
<head>
<title>Procedure stocke</title>
</head>
<body>
<Form name="Form1" method="get"
action="\TATA\servlet\SupprimerServlet">
<p>Pour supprimer un prospect</p>
<p>Entrez un numero de prospect: <input type="text" name="number" > </p>
<p><input type="submit" name="Submit" rows"5" value="ok"></p>
</Form>
</body>
</html>
je mets le fichier html directement sous tata.
Le fichier supprimerServlet.class dans web-inf ,classes
dans web-inf ,lib je mets servlet-api-2.4.jar
dans web-inf , src je mets supprimerServlet.java
dans web-inf ,je mets le fichier web.xml ci dessous
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
 
<web-app>
<display-name>SupprimerServlet</display-name>
<description>test de la servlet java </description>
<servlet>
<servlet-name>SupprimerServlet</servlet-name>
<servlet-class>SupprimerServlet</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>SupprimerServlet</servlet-name>
<url-pattern>tata/SupprimerServlet</url-pattern>
</servlet-mapping>
</web-app>
Merci de votre aide