bonjour,
je possède une page jsp qui contient un bouton qui a pour role de démarrer un thread java.le problème c'est que le thread n'est jamais démarré et je ne trouve pas de trace dans mes logs sous netbeans.
voici mon code 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 <%-- Document : newjsp Created on : Oct 8, 2013, 4:32:55 PM Author : stoner2008 --%> <%@page import="com.beans.Util"%> <%@page import="java.util.List"%> <%@page import="java.util.ArrayList"%> <%@ page language="java" import="com.programmingfree.salesreport.*"%> <%@page contentType="text/html" pageEncoding="UTF-8"%> <!DOCTYPE html> <html> <h:head> <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"/> <title> Validation </title> <link href="css/demo_page.css" rel="stylesheet" type="text/css" /> <link href="css/demo_table.css" rel="stylesheet" type="text/css" /> <link href="css/demo_table_jui.css" rel="stylesheet" type="text/css" /> <link href="css/jquery-ui-1.8.24.custom.css" rel="stylesheet" type="text/css" media="all" /> <script src="js/jquery.js" type="text/javascript"></script> <script src="js/jquery.dataTables.js" type="text/javascript"></script> <script type="text/javascript"> //<![CDATA[ $(document).ready(function() { $("#companies").dataTable({ "sPaginationType": "full_numbers", "bJQueryUI": true }); }); //]]> </script> </h:head> <h:body> <div id="container"> <h1>Donnée Clients</h1> <div id="demo_jui"> <table id="username" class="display"> <thead> <tr> <th><u>Prénoms</u></th> <th><u>Noms</u></th> <th><u>Option1</u></th> <th><u>Option2</u></th> </tr> </thead> <tbody> <% for (SalesReport c : FetchDataFromDb.GetSalesData()) {%> <tr> <td><%=c.getval0()%></td> <td><%=c.getval()%></td> <td><%=c.getVal()%></td> <td><%=c.getVal1()%></td> </tr> <% } %> </tbody> </table> </div> </div> <br/><br/> <% HttpSession session1 = Util.getSession(); String s = session.getAttribute("username").toString(); out.println("le surnom est "+s); %> <input type="submit" value="valider" name="valider" onclick=#{runThread.run1()}/> </h:body> </html>
voici le code pour le thread
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 import com.beans.Util; import com.util.Commons; import java.io.InputStream; import java.net.URL; import java.sql.Connection; import java.sql.PreparedStatement; import java.sql.ResultSet; import java.sql.SQLException; import java.sql.Statement; import java.util.Properties; import javax.faces.bean.ManagedBean; import javax.faces.bean.SessionScoped; import javax.servlet.http.HttpSession; import org.apache.log4j.Logger; @ManagedBean(name="runThread") @SessionScoped public class RunThread{ public void run1() { try { int delay = 5000; URL url = new URL("http://stoner2008.com/test/"); String URL=url.toString(); System.out.println(" url -->"+URL); String ShortNumber ="smart"; DemarrerService(URL, ShortNumber); //Timer t1 = new Timer(); //t1.schedule(new RunThread(), delay); } catch (Exception e) { //log.error(e.getMessage()); e.printStackTrace(); } } public static void DemarrerService(String URL, String ShortNumber) { Connection connection=null; Statement stmt1=null; ResultSet rset1=null; Statement stmt2=null; ResultSet rset2=null; System.out.println("---------------------------------- avant getsession"); HttpSession session = Util.getSession(); String id=""; String header="boubou"; String phoneNumber=""; System.out.println("------------------------------ avant getattribute -----------------"); header=session.getAttribute("header").toString(); String sql="select id,username,pass from "+header+" where traiter='non'"; try{ System.out.println("------------------------------ test-----------------"); } } } stmt1.close(); //stmt2.close(); } catch(Exception e){ e.printStackTrace(); } }
Partager