Comment get toutes datatables déposées récupérées dans excel dans jsp

J'utilise ce code, mais seule une rangée de données de table est input dans un file … J'utilise la database mysql. la connection est établie dans connection.jsp. tablename est une connection. en utilisant le file poi-2.5.1.jar. ce code fonctionne sans aucune erreur, mais comment intégrer des données de table entières dans la feuille Excel

<%@page contentType="text/html" pageEncoding="UTF-8"%> <!DOCTYPE html> <html> <%@page import="java.sql.*"%> <%@pageimport="java.util.*,java.io.*,javax.servlet.*,javax.servlet.http.*"%> <%@ page import="java.io.*"%> <%@include file="connection.jsp" %> <%@page import=" org.apache.poi.hssf.usermodel.*"%> <head> <meta httpequiv="ContentType"content="text/html;charset=UTF-8"> <title>JSP Page</title> </head> <% response.setContentType("application/xls"); response.setHeader("ContentDisposition","attachment;filename=File.xls"); %> <body> <table> <tr><th>CG</th><th>CD</th></tr> <% Statement stmt = conn.createStatement(); Ssortingng filename="C:/Users/sangu/Downloads/data.xls" ; HSSFWorkbook hwb=new HSSFWorkbook(); HSSFSheet sheet = hwb.createSheet("sheet"); HSSFRow row= sheet.createRow((short)0); ResultSet res = stmt.executeQuery("select * from login "); while (res.next()) { Ssortingng cg = res.getSsortingng(1); Ssortingng cd = res.getSsortingng(3); row.createCell((short) 0).setCellValue(cd); row.createCell((short) 1).setCellValue(cd); row.createCell((short) 1).setCellValue(cd); %> <tr> <td align="center"><%=cg%></td> <td align="center"><%=cd%></td> </tr> <% FileOutputStream fileOut = new FileOutputStream(filename); hwb.write(fileOut); fileOut.close(); out.println("Your excel file has been generated!"); hwb.write(response.getOutputStream()); } %> </table> </body> </html> 

Ne sait pas avec certitude mais ne doit pas être HSSFRow row= sheet.createRow((short)0); à l'intérieur en boucle? de sorte qu'il créera une nouvelle ligne pour chaque résultat?

MODIFIER:

  Statement stmt = conn.createStatement(); Ssortingng filename="C:/Users/sangu/Downloads/data.xls" ; HSSFWorkbook hwb=new HSSFWorkbook(); HSSFSheet sheet = hwb.createSheet("sheet"); ResultSet res = stmt.executeQuery("select * from login "); while (res.next()) { HSSFRow row= sheet.createRow((short)0); Ssortingng cg = res.getSsortingng(1); Ssortingng cd = res.getSsortingng(3); row.createCell((short) 0).setCellValue(cd); row.createCell((short) 1).setCellValue(cd); row.createCell((short) 1).setCellValue(cd); %> <tr> <td align="center"><%=cg%></td> <td align="center"><%=cd%></td> </tr> <% FileOutputStream fileOut = new FileOutputStream(filename); hwb.write(fileOut); fileOut.close(); out.println("Your excel file has been generated!"); hwb.write(response.getOutputStream()); }