Win a copy of Practical SVG this week in the HTML/CSS/JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Jasperreports + Struts

Manuel Sanchez Iba�ez
Posts: 20
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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);


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);
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?
Did you just should on me? You should read this tiny ad:
the new thread boost feature brings a LOT of attention to your favorite threads
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!