Jump to content
Changes to the Jaspersoft community edition download ×

BatchExport with JSP

2004 IR Help

Recommended Posts

By: vedantaulises - vedantaulises

BatchExport with JSP

2005-07-14 03:39

Hi experts,


I want to create a batch report(using more than one jrxml files).

I have read the example on batchexport, but my requirement is more.

I want to use an applet using JRViewer on the client browsers.

but I haven't successed yet to accomplish this project.


The brief what I have done is:

1. I'm using sample from webapp/applet sample and modified them.


2. Modified JRViewerSimple, add one more constructor that is



* I plan to use an Inputstream that contains an XML Stream file

* @param InputStream is

* @throws JRException


public JRViewerSimple(InputStream is) throws JRException{

super(is, true);


3. Modified method init from EmbeddedViewerApplet.


public void init()


String url = getParameter("REPORT_URL");

if (url != null)




URL _url = new URL(getCodeBase(), url);

JRViewerSimple viewer = new JRViewerSimple(_url.openStream());

this.pnlMain.add(viewer, BorderLayout.CENTER);


catch (Exception e)


StringWriter swriter = new StringWriter();

PrintWriter pwriter = new PrintWriter(swriter);


JOptionPane.showMessageDialog(this, swriter.toString());





JOptionPane.showMessageDialog(this, "Source URL not specified");




4. I'm using Action(from struts action to generate the JasperPrint and JasperPrintList.

the snippet code is:

// defined masterBean

MasterDAO _masterDao = (MasterDao)getBean("masterDao");


// defined the Object invoice

Invoice _invoice = _masterDao.getInvoice(id);


// define the map

Map _map = new HashMap();

_map.put("invoice", _inovoice);


//populate the jasperPrints

JasperPrint _printCover = JasperFillManager.fillReport(getJasperReport("jasper.invoice.cover", request), _map, new JREmptyDataSource());

JasperPrint _printInvoice = JasperFillManager.fillReport(getJasperReport("jasper.invoice.invoice", request), _map, new JREmptyDataSource());

JasperPrint _printConfirm = JasperFillManager.fillReport(getJasperReport("jasper.invoice.confirm", request), _map, new JREmptyDataSource());


ArrayList _jasperPrintList = new ArrayList();




try {

JRXmlExporter _exporter = new JRXmlExporter();

_exporter.setParameter(JRExporterParameter.JASPER_PRINT_LIST, _jasperPrintList);

_exporter.setParameter(JRExporterParameter.OUTPUT_STREAM, _oos);


_oos.flush(); //<== error happend in this,


} catch (JRException e) {

_messages.add(ActionMessages.GLOBAL_MESSAGE, new ActionMessage("error.process.failed", e.getMessage()));

} catch (IOException e) {

_messages.add(ActionMessages.GLOBAL_MESSAGE, new ActionMessage("error.process.failed", e.getMessage()));


if (_messages.size()>0){

saveMessages(request, _messages);

_forward = mapping.findForward("error");


return _forward;


May be what I've done was not in correct direction.

If anyone have done such this thing running well, could you

share some thing code or clues,


Thanks in advance






By: vedantaulises - vedantaulises

RE: BatchExport with JSP

2005-07-15 06:25

I want to make it clear.

What I need is to parsing some JasperPrint or concating many report into EmbeddedViewerApplet or some similar applet.





By: vedantaulises - vedantaulises

RE: BatchExport with JSP

2005-07-15 11:24

Now I found the solution of my problem and questions !!


The solution is easy. Just add the additional pages to the one.

the codes are:


private void addPages(JasperPrint dest, JasperPrint src){

List _additionalPages = src.getPages();

for (int i=0; i < _additionalPages.size(); i++){

dest.addPage((JRPrintPage) _additionalPages.get(i));



public ActionForward execute(...){


JasperPrint _printReport1 = null;

JasperPrint _printReport2 = null;

JasperPrint _printReport3 = null;


ObjectOutputStream _oos = new ObjectOutputStream(response.getOutputStream());

addPages(_printReport1, _printReport2);

addPages(_printReport1, _printReport3);






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