Again though, I'm using Struts too. Struts sets up all sorts
of variables for me (request.setAttribute(...)) that I can access
in my JSP page. I'm pretty new at this stuff, and although I
think I see how to modify the struts-config.xml file to map the
action to a servlet, what I don't see is an easy way to access
those variables from the servlet.

Now that I've gotten rid of that last newline character, I'm
hoping it's going to be fairly smooth sailing from here. ;)

Thanks,
---John


--- Paulo Soares <[EMAIL PROTECTED]> wrote:

> That's why a servlet is always a better option.
> 
> > -----Original Message-----
> > From: John M. Gabriele [mailto:[EMAIL PROTECTED] 
> > Sent: Friday, July 08, 2005 3:59 PM
> > To: Paulo Soares; itext-questions@lists.sourceforge.net
> > Subject: Re: [iText-questions] Struts, JSP --> PDF. 
> > getOutputStream() already called
> > 
> > Thanks for the reply Paulo.
> > 
> > I removed *all* the whitespace outside of those <%@ ... %><% ... %>
> > symbols, but it still gave me the same error.
> > 
> > But then I opened the file in a hex editor and found that my editor
> > was secretly placing one \n at the end of the file! I deleted that one
> > last newline at the end of the jsp, and now it works. :)
> > 
> > Thanks!!
> > 
> > For reference, the hex editor I use is ncurses-hexedit:
> > http://www.rogoyski.com/adam/programs/hexedit/
> > 
> > 
> > --- Paulo Soares <[EMAIL PROTECTED]> wrote:
> > 
> > > 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
> > > 
> > 
> > 
> > 
> >             
> > ____________________________________________________
> > Sell on Yahoo! Auctions - no fees. Bid on great items.  
> > http://auctions.yahoo.com/
> > 
> 



                
____________________________________________________
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

Reply via email to