Hi

I'm trying to generate PDF from .jsp code (using jakarta-tomcat) but not
successfully. It goes like

<%@
page import="java.io.*,
                         com.lowagie.text.*,
                         com.lowagie.text.pdf.*"

%>
<%

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] ); }
%>

Sample code taken from itext

i get the following error

Error: 500
Location: /wls/cmweb/pdfgeneration.jsp
Internal Servlet Error:

java.lang.IllegalStateException: OutputStream is already being used for this 
request
        at 
org.apache.tomcat.facade.HttpServletResponseFacade.getWriter(HttpServletResponseFacade.java:175)
        at org.apache.jasper.runtime.JspWriterImpl.initOut(JspWriterImpl.java:166)
        at 
org.apache.jasper.runtime.JspWriterImpl.flushBuffer(JspWriterImpl.java:158)




Anand




_________________________________________________________________
Unlimited Internet access for only $21.95/month.� Try MSN! 
http://resourcecenter.msn.com/access/plans/2monthsfree.asp



-------------------------------------------------------
This sf.net email is sponsored by: viaVerio will pay you up to
$1,000 for every account that you consolidate with us.
http://ad.doubleclick.net/clk;4749864;7604308;v?
http://www.viaverio.com/consolidator/osdn.cfm
_______________________________________________
iText-questions mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/itext-questions

Reply via email to