Ho provato con questo codice
codice:
<%@
page import="java.io.*,
com.lowagie.text.*,
com.lowagie.text.pdf.*"
%><%
//
// Template JSP file for iText
// by Tal Liron
//
response.setContentType( "application/pdf" );
// step 1: creation of a document-object
Document document = new Document();
// step 2:
// we create a writer that listens to the document
// and directs a PDF-stream to a temporary buffer
ByteArrayOutputStream buffer = new ByteArrayOutputStream();
PdfWriter.getInstance (document, buffer);
// step 3: we open the document
document.open();
// step 4: we add a paragraph to the document
document.add(new Paragraph("Hello World"));
// step 5: we close the document
document.close();
// step 6: we output the writer as bytes to the response output
DataOutput output = new DataOutputStream( response.getOutputStream() );
byte[] bytes = buffer.toByteArray();
response.setContentLength(bytes.length);
for( int i = 0; i < bytes.length; i++ ) { output.writeByte( bytes[i] ); }
%>
ed effettivamente, mandando in esecuzione, compare la finestrella del download per eseguire il salvataggio del file creato...ed è dunque quello che voglio...purtoppo però viene impostato automaticamente il nome del file con il nome del file .jsp....cioè se chiamo la pagina del codice sopra postato "Prova.jsp"....viene impostato il file .PDF creato con il nome "Prova.jsp.pdf"....è vero che poi dalla finestrella, prima di scegliere il path del salvataggio, è possibile cambiare il nome del file...ma io vorrei settarlo dal codice...come fare???
Grazie