I am using JapserReports
for showing reports in Java. I am able to send report in PDF
format to the web browser.
Now I want to send the report in HTML
format, following is my method for sending report in HTML
format.
protected void processRequest(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException
{
File reportFile = new File(getServletConfig().getServletContext().getRealPath("/rpts/report1.jasper"));
ServletOutputStream servletOutputStream = response.getOutputStream();
byte[] bytes = null;
Map<String,Object> parameter = new HashMap<String,Object>();
Connection con = DBConnection.getConnection("");
try
{
bytes = JasperRunManager.runReportToHtmlFile(reportFile.getPath(),parameter,con).getBytes();
response.setContentType("text/html");
response.setContentLength(bytes.length);
servletOutputStream.write(bytes, 0, bytes.length);
servletOutputStream.flush();
servletOutputStream.close();
}
catch (JRException e)
{
System.out.println(e);
}
}
Above method is printing path
of generated HTML
file. When I check the path then HTML
file was generated there with the data.
So am i missing something in the code?
Thanks in advance....