Bonjour,
J'ai mon code en java ee qui fonctionne très bien en local sous apache tomcat 7.0.42.
Mais arrivé en ligne il est impossible d’exécuté mes rapport impression.
Voici comment je fait appel a ma fonction imprimer dans mon controller.
Et voici ma fonction imprimer
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13 if (action.equals("print")) { String id1 = (request.getParameter("id")) != null ? request.getParameter("id") : ""; String path=null; HashMap<String, Integer> map = new HashMap<String, Integer>(); if(id1.equals("") || id1.equals(null)){ path=session.getServletContext().getRealPath("/Reports/ListArtisansTotal.jrxml"); }else{ map.put("id",Integer.parseInt(id1)); path=session.getServletContext().getRealPath("/Reports/ArtisansRegistre.jrxml"); } utilitaire.imprimer(path, response,map); }
Et enfin la capture de l'erreur du serveur
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 public void imprimer(String path_jrxml, HttpServletResponse response,HashMap map) { Connection conn = DBUtil.getConnection(); try { String jrxmlFile = path_jrxml; InputStream input = new FileInputStream(new File(jrxmlFile)); // Generating the report JasperReport jasperReport = JasperCompileManager.compileReport(input); JasperPrint jasperPrint = JasperFillManager.fillReport(jasperReport, map, conn); // Exporting the report as a PDF JasperExportManager.exportReportToPdfStream(jasperPrint, response.getOutputStream()); } catch (FileNotFoundException e) { e.printStackTrace(); } catch (JRException e) { e.printStackTrace(); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } finally { } }
Merci d'avance parsque je galère grave!!
Partager