Jump to content
Changes to the Jaspersoft community edition download ×

Someone can help me (Servlets results mixed)?


Recommended Posts

By: Sam - ssa00319

Someone can help me (Servlets results mixed)?

2003-04-22 09:28

Hi everybody,

 

I've 2 servlets (jdsk 2.0) : one to export in XML and another one to export in CSV.

They work fine (thank for this wonderful tool !!) but only if i invoque one of them and not another one just after. For example :

- i launch the servlet CSVexport : ok, perfect.

- i launch the servlet XMLexport (after end of CSVexport) : i've a piece of CSVexport at the start of response and after, the XML code... (idem if i launch XMLexport before CSVexport).

 

This is the code used to write to response object in my servlets :

JasperReport jasperReport =

(JasperReport) JRLoader.loadObject(reportFile.getPath());

JasperPrint jasperPrint = JasperFillManager.fillReport(

jasperReport,

parameters,

dbCnx);

 

ByteArrayOutputStream reportOutputStream = new ByteArrayOutputStream();

JRCsvExporter exporter = new JRCsvExporter();

exporter.setParameter(JRExporterParameter.JASPER_PRINT, jasperPrint);

exporter.setParameter(JRExporterParameter.OUTPUT_STREAM, reportOutputStream);

exporter.exportReport();

byte[] bytes = reportOutputStream.toByteArray();

response.setContentType("text/plain");

response.setContentLength(bytes.length);

ServletOutputStream servletOutputStream = response.getOutputStream();

reportOutputStream.writeTo(servletOutputStream);

servletOutputStream.write(bytes, 0, bytes.length);

servletOutputStream.flush();

servletOutputStream.close();

 

In fact, problem seems not to be from jasperreport (if i print reportOutputStream, it's ok even if result is not good) but after (from servletOutputStream ?)...

Can I try a clear of something before writing in it (i'm in servlets 2.0 with jsdk 2.0) or something else ?

 

I'am a niewbie and really need help !

 

Thanks a lot,

Dom,

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...