Remove all the withe space in the JSP. For example:

com.lowagie.text.pdf.*"
%>

<%
response.setContentType( "application/pdf" );

should be:

com.lowagie.text.pdf.*"
%><%
response.setContentType( "application/pdf" );

----- Original Message ----- 
From: "John M. Gabriele" <[EMAIL PROTECTED]>
To: <itext-questions@lists.sourceforge.net>
Sent: Thursday, July 07, 2005 9:35 PM
Subject: [iText-questions] Struts, JSP --> PDF. getOutputStream() already
called


I'm trying to drop a small JSP page into an existing webapp that uses
Struts.
Struts sets up a bunch of variables for me that I can access in the JSP
page,
and I want to take the values of those variables and incorporate them into
a PDF that I send back to the user.

1. I've got the hello world JSP page (from the iText web site):

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

<%
response.setContentType( "application/pdf" );
Document document = new Document();

// 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 );

document.open();

document.add( new Paragraph( "Hello World!" ) );

document.close();

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

and I've dropped the itext-1.3.1.jar file into my WEB-INF/lib directory,
but when I try and access the jsp in my browser, Tomcat complains telling
me:

java.lang.IllegalStateException: getOutputStream() has already been called
for
this response

How can I make a simple JSP, that generates a PDF, work in my existing
Struts
webapp?




____________________________________________________
Sell on Yahoo! Auctions - no fees. Bid on great items.
http://auctions.yahoo.com/


-------------------------------------------------------
This SF.Net email is sponsored by the 'Do More With Dual!' webinar happening
July 14 at 8am PDT/11am EDT. We invite you to explore the latest in dual
core and dual graphics technology at this free one hour event hosted by HP,
AMD, and NVIDIA.  To register visit http://www.hp.com/go/dualwebinar
_______________________________________________
iText-questions mailing list
iText-questions@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/itext-questions



-------------------------------------------------------
This SF.Net email is sponsored by the 'Do More With Dual!' webinar happening
July 14 at 8am PDT/11am EDT. We invite you to explore the latest in dual
core and dual graphics technology at this free one hour event hosted by HP, 
AMD, and NVIDIA.  To register visit http://www.hp.com/go/dualwebinar
_______________________________________________
iText-questions mailing list
iText-questions@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/itext-questions

Reply via email to