|
Publicité ' | |||||||||||||||||||||||
|
|
#1 |
|
Invité de passage
![]() Inscription : août 2006 Messages : 3 ![]() |
j'ai réalisé une petite application Web qui integre l'api jasperreports et je souhaite envoyer des rapports sur n'importe quel navigateur pour l'imprimer.
j'ai créé la servlet suivante: public class PrintFileToScreen extends javax.servlet.http.HttpServlet implements javax.servlet.Servlet { public final static String URL="jdbc:postgresql://192.168.1.2:5432/tunicode"; public final static String USER_NAME="postgres"; public final static String PASSWORD="postgres"; public PrintFileToScreen() { super(); } protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { try { Class.forName("org.postgresql.Driver"); } catch (ClassNotFoundException e1) { // TODO Auto-generated catch block e1.printStackTrace(); } Connection conn=null; try { conn = DriverManager.getConnection(URL, USER_NAME, PASSWORD); } catch (SQLException e1) { // TODO Auto-generated catch block e1.printStackTrace(); } //getting file name From System File String file_name=request.getParameter("Path"); System.out.println("File report :"+file_name); //make report here // chemin du rapport File reportFile = new File(file_name); // remplissage du map des parmètres // generation du rapport try { byte [] bytes = JasperRunManager.runReportToPdf(reportFile.getPath(),null,conn); FileOutPut response. } catch (JRException e) { // TODO Auto-generated catch block e.printStackTrace(); } } } *-------------------------------------------------------* comme mentionner le rapport et déja génerer mais mon probléme consiste a récupérer les "bytes" sur une interface Web... |
|
|
00
|
|
|
#2 | |
|
Invité de passage
![]() Inscription : mars 2005 Messages : 4 ![]() |
Bonjour Tarak,
je ne comprend pas trop votre question! ton code me semble correcte et il permet de généré vote rapport sous format PDF. Si vous voulez le générer sous format html, vous pouvez utiliser le code suivant : Citation:
|
|
|
|
00
|
Copyright © 2000-2012 - www.developpez.com