This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
The moose likes Other Open Source Projects and the fly likes Jasperreports + Struts Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Products » Other Open Source Projects
Bookmark "Jasperreports + Struts" Watch "Jasperreports + Struts" New topic
Author

Jasperreports + Struts

Manuel Sanchez Iba�ez
Greenhorn

Joined: Jul 12, 2005
Posts: 20
Hello and sorry for my english. I have an web application based in Struts.
I have to create some reports and i use jasperrerport. I have seen code for creating reports in jsp pages but i want create the report in a Action class :

public ActionForward MostrarDiarioSesionesAction (ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception{
...
File reportFile = new File(request.getRealPath("/reports/diariosesiones.jasper"));

JasperPrint jasperPrint = JasperFillManager.fillReport(reportFile.getPath(),parametros,conexion);
JasperViewer.viewReport(jasperPrint,false);

conexion.close();

return (mapping.findForward("success"));
}


In my localhost webserver (tomcat), the report work fine but if i prove this code in a hosting server, the application throws an error (null).

I suppose, the error is due to using JasperWiewer. Then, i can put:

...
File reportFile = new File(request.getRealPath("/reports/diariosesiones.jasper"));
byte[] bytes = JasperRunManager.runReportToPdf(reportFile.getPath(),parametros,conexion);
response.setContentType("application/pdf");
response.setContentLength(bytes.length);
ServletOutputStream ouputStream = response.getOutputStream();
ouputStream.write(bytes, 0, bytes.length);

return (mapping.findForward("success"));
}

This code too work fine but so the report take more time than using JasperWiewer.

�Do you know if can i use JasperWiewer in application web store in hosting?
�Is there any wrong thing?
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Jasperreports + Struts
 
Similar Threads
Urgent! Strange problem when calling jasper report in STRUTS
Jasper Reports Excel Output
iReports - HTML format in JSP
JSP and iReports without database connection
iReport in Struts action