je vous explique la situation:je récupère une liste à travers json et je l'affiche en utilisant jquery et datatable (plusieurs pages).ça se passe sans problème.
je voulais extraire toutes les lignes de la datatable mais ça ne marche pas.J'ai essayé avec table tools et avec plusieurs code javascript mis ça ne marche pas.j'ai toujours seulement la première page qui est extraite en csv mais pas les autres pages.du cout je vais créer une page jsp (coté serveur) qui renvoi un csv mais je ne sais pas comment faire. J'ai sauvegardé le contenu de ma requete dans une arrayList et maintenant je veux exporter son contenu et le renvoyer directement au client lors du chargement de la page mais je suis bloqué.
voiçi mon code

voiçi la page qui affiche le contenu de la datatable.les informations sont reçues par json
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
<%@ page language="java" import="java.text.*, java.util.*,java.io.*,org.apache.poi.poifs.filesystem.POIFSFileSystem,org.apache.poi
.hssf.record.*,org.apache.poi.hssf.model.*,org.apache.poi.hssf.usermodel.*,java.sql.*" pageEncoding="UTF-8" %>
<%@ page import="java.sql.ResultSet" %>
<html>
<head>
	<meta http-equiv="content-type" content="text/html; charset=utf-8">
	 <title>Details Participations</title>
     <style type="text/css" title="currentStyle">
			@import "datatable/media/css/demo_page.css";
			@import "datatable/media/css/demo_table_jui.css";
			@import "datatable/examples/examples_support/themes/smoothness/jquery-ui-1.8.4.custom.css";
	</style>
  <script type="text/JavaScript">
<!--
function timedRefresh(timeoutPeriod) 
{
        setTimeout("location.reload(true);",timeoutPeriod);
}
//   -->
  </script>
  <script type="text/javascript" charset="utf-8" src="datatable/media/js/jquery.js"></script>
  <script type="text/javascript" language="javascript" src="datatable/media/js/jquery.js"></script>
  <script type="text/javascript" language="javascript" src="datatable/media/js/jquery.dataTables.js"></script>
  <script type="text/javascript" language="javascript" src="datatable/media/js/jquery.dataTables.min.js"></script>
  <script type="text/javascript" src="dataTables.fnDraw.js"></script>
 
 
	<script type="text/javascript" language="javascript" src="jquery/dataTables.tableTools.min.js"></script>
	<script type="text/javascript" language="javascript" src="jquery/dataTables.tableTools.js"></script>
 
  <script type="text/javascript" charset="utf-8">
 
 
                var oTable;
                        $(document).ready(function () {
                                $('#example').dataTable( {
 
 
                                        "bProcessing": true,
                                        "bServerSide": true,
                                        "sAjaxSource": "http://testXXXX.com/test/json.jsp",
                                        "bDestroy": false,
                                         "bRetrieve": true,
                                        "bJQueryUI": true,
                                        "sPaginationType": "full_numbers",
                                        "bStateSave": true,     
                                        "pages": "all",
 
                                        "iDisplayLength": 10,
                                         "dom": 'T<"clear">lfrtip',
        "tableTools": {
            "sSwfPath": "swf/copy_csv_xls.swf",
 
                        "aButtons": [
 
            {
                "sExtends": "xls",
                "oSelectorOpts": { filter: 'applied', order: 'current' },
                "sFileName": "Dlilek_mlak.xls"
            },
            {
                "sExtends": "pdf",
                "oSelectorOpts": { filter: 'applied', order: 'current' },
                "sFileName": "Dlilek_Mlak.pdf",
                "sPdfOrientation": "landscape",
                "sPdfMessage": "Account List" + ($('div.dataTables_filter input').length > 0 ? " Filter: " + $('div.dataTables_filter input').val() : "")
            },
            {
                "sExtends": "print",
                "oSelectorOpts": { filter: 'applied', order: 'current' },
            }
            ]
        },
 
 
                                        } );
                        } );
 
 
 
 
  </script>
</head>
<body id="">
 
 <div class="demo_jui">
  <table cellpadding="0" cellspacing="0" align="center" border="0" class="display" id="example">
	<thead>
		<tr>
			<th width="50" style="color:blue;">ID</th>
			<th width="100" style="color:blue;">Phone</th>
		   	<th width="300" style="color:blue;">Message</th>
		    <th width="150" style="color:blue;">Date</th>	
		</tr>
	</thead>
  </table>
 </div>
 
</body>
</html>

et voiçi la page coté serveur qui va sauvegarder le contenu de la requete dans un arraylist
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
<%@page import="java.util.*"%>
<%@page import="java.sql.*,com.ConnectionPool"%>
<%@page import="org.json.*"%>
<%@page import="net.sf.json.JSONObject"%>
<%@page import="net.sf.json.JSONArray"%>
<%@ page language="java" import="java.text.*, java.util.*,java.io.*,org.apache.poi.poifs.filesystem.POIFSFileSystem,org.apache.poi
.hssf.record.*,org.apache.poi.hssf.model.*,org.apache.poi.hssf.usermodel.*,java.sql.*" pageEncoding="UTF-8" %>
<%@ page import="java.sql.ResultSet" %>
 <%   
   java.util.Date now = new java.util.Date();
   SimpleDateFormat format = new SimpleDateFormat("dd/MM/yyyy");
   String Current_date = format.format(now);
       
   String DateDebut = (String)session.getAttribute("DateDebut");
   if (DateDebut == null || DateDebut.equals("")  )  DateDebut=Current_date;
   
   String DateFin = (String)session.getAttribute("DateFin");
   if (DateFin == null || DateFin.equals("") )  DateFin=Current_date; 
      String[] cols = {"id", "num_tel", "nom", "date"  };
 
        String table = "table";
        JSONObject result = new JSONObject();
        JSONArray array = new JSONArray();
        
        ArrayList arraylist1= new ArrayList();
        ArrayList arraylist2= new ArrayList();
        
        int amount = 10;
        int start = 0;
        int echo = 0;
        int col = 0;
        
          // set up handle to file name.
                  String jj = DateDebut.substring(0,2);
              String mm = DateDebut.substring(3,5);
              String aaaa = DateDebut.substring(6,10);              
              String newformat = aaaa+"-"+mm+"-"+jj;
              
               jj = DateFin.substring(0,2);
               mm = DateFin.substring(3,5);
               aaaa = DateFin.substring(6,10);    
               String newformatEnd = aaaa+"-"+mm+"-"+jj;
        String id = "";
        String num_tel = "";
 
        String date = "";
    String nom="";
        String dir = "desc";
        
        
 
        Statement stmt = null;
        
        
        String colName = cols[col];
        int total = 0;
        Connection conn = ConnectionPool.getGatewayConnection();
        stmt = conn.createStatement();
        
        try {
                String searchSQL = "";
                String sql = "SELECT * FROM "+table+"  where  rec_date between  '"+newformat+" 00:00:00' and '"+newformatEnd+" 23:59:59' ";
        
            
                
                
                //sql += " order by " + colName + " " + dir;
        //      sql += " limit " + (amount) + " OFFSET " + start;
                
                PreparedStatement ps = conn.prepareStatement(sql);
                ResultSet rs = ps.executeQuery();
                while (rs.next()) 
                {
                        JSONArray ja = new JSONArray();
                        ja.put(rs.getString("id"));
                        ja.put(rs.getString("recid"));
                        ja.put(rs.getString("num_tel"));
                
                        ja.put(rs.getString("nom"));
                        ja.put(rs.getString("rec_date"));
        
                        array.put(ja);
                
                        arraylist1.add(rs.getString("recid"));
                        arraylist1.add(rs.getString("num_tel"));
                        arraylist1.add(rs.getString("nom"));
                        arraylist1.add(rs.getString("rec_date"));
                        
                        arraylist2.add(arraylist1);
                }
                
                
                String exportToExcel = "YES";
                
                //String exportToExcel = request.getParameter("exportToExcel");
                if (exportToExcel != null
                                && exportToExcel.toString().equalsIgnoreCase("YES")) {
                response.setContentType("application/vnd.ms-excel");
                        response.setHeader("Content-Disposition", "inline; filename="
                                        + "excel.xls");}
                                        
                //response.setContentType("application/json");
        //      response.setHeader("Cache-Control", "no-store");
                
        
                
                out.print(arraylist2);
                //      out.print(result);
                conn.close();
        } 
        catch (Exception e) 
        {
                e.getStackTrace();
                e.printStackTrace();
        }
%>