Jump to content
JasperReports Library 7.0 is now available ×

Attaching to jsp


mdhoffman

Recommended Posts

This is the first time I've used iReport in an application and I'm trying to load it on my jsp page. I've found a few examples on different sites, but I can't get any of them to work. Right now I have:

 

// Set class path for compiling XML templates

ServletContext context;

System.setProperty("jasper.reports.compile.class.path",context.getRealPath("/WEB-INF/lib/jasperreports-0.6.1.jar") + System.getProperty("path.separator") + context.getRealPath("C:/Data/Projects/Java/oChequeManager/classes/"));

 

// Specify a default folder for storing

// compiled XML templates

System.setProperty("jasper.reports.compile.temp",context.getRealPath("C:/java/Jasper/buildTests/"));

 

JasperCompileManager.compileReportToFile(getServletContext().getRealPath("C:/java/Jasper/buildTests/TransactionSearch.xml"));

 

File reportFile = new File(getServletContext().getRealPath("C:/java/Jasper/buildTests/TransactionSearch.jasper"));

JasperReport jasperReport = (JasperReport) new JRLoader().loadObject(reportFile.getPath());

 

JasperPrint jasperPrint = JasperManager.fillReport(jasperReport, new HashMap(), new JREmptyDataSource());

 

JRHtmlExporter exporter = new JRHtmlExporter();

JRHtmlExporterParameter exporterParameter;

exporter.setParameter(exporterParameter.JASPER_PRINT, jasperPrint);

exporter.setParameter(exporterParameter.OUTPUT_WRITER,response.getWriter());

Map imagesMap = new HashMap();

request.getSession().setAttribute("IMAGES_MAP", imagesMap);

exporter.setParameter(exporterParameter.IMAGES_MAP, imagesMap);

exporter.setParameter(exporterParameter.IMAGES_URI,"image?image=");

exporter.exportReport();

 

 

 

I'm getting two errors - a couple of initialization errors and uses or overrides a deprecated API error. If anyone knows of a good way to bring iReports into jsp it would be very helpful.

Link to comment
Share on other sites

  • Replies 0
  • Created
  • Last Reply

Top Posters In This Topic

Popular Days

Top Posters In This Topic

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×
×
  • Create New...