I have not been able to find the solution to be able to export a report to excel. I managed to export it in pdf format in a dynamic web project in eclipse.
File reportfile = new File (application.getRealPath("empleado.jasper"));
Map<String,Object> parameter = new HashMap<String,Object>();
String valor1 = request.getParameter("txtparametro1");
parameter.put("valo",new String(valor1));
String valor2 = request.getParameter("txtparametro2");
parameter.put("valor",new String(valor2));
byte[] bytes = JasperRunManager.runReportToPdf(reportfile.getPath(), parameter,con);
response.setContentType("application/pdf");
response.setContentLength(bytes.length);
ServletOutputStream outputstream = response.getOutputStream();
outputstream.write(bytes,0,bytes.length);
outputstream.flush();
outputstream.close();
%>
All of the above, including the connection, are made within the WEB-INF in .jsp files and I would like the export in excel to be also in .jsp.
Someone who can help me, I would really appreciate it.