nella pagina viene invocato un metodo della action che si occupa di creare un file zip,
ecco il metodo:
codice:
ZipOutputStream outZip = null;
try{
byte[] file;
HttpServletResponse httpResponse = ServletActionContext.getResponse();
httpResponse.setHeader("Content-Disposition", "attachment; filename="+"InPagamento.zip");
outZip= new ZipOutputStream(httpResponse.getOutputStream());
for (int i =0 ; i<this.dataSourceLotti.size(); i++) {
lotto = this.dataSourceLotti.get(i);
file = this.stampaASS1AUT(IP6BIS);
outZip.putNextEntry(new ZipEntry(nomePDF + ".pdf"));
outZip.write(file);
outZip.closeEntry();
}
//httpResponse.getOutputStream().flush();
outZip.close();
}
catch(Exception ex){
this.gestioneEccezione(ex);
//return PAGAMENTO_TILES;
}
Il file zip contenente i pdf viene creato, pero' nella console compare l'eccezione java.lang.IllegalStateException: SRVE0199E: OutputStream already obtained e quindi non posso eseguire il return PAGAMENTO_TILES;motivo per cui tale istruzione è commentata.
La spiegazione che mi sono dato è che la jsp viene trasformata in una servlet che aprirà a prescindere da ciò un outputStream, quindi non si possono aprire 2 stream nella stessa pagina....ma come è possibile?