I have a simple servlet that creates a PDF  

I'm using TomCat 4.0 and Jbuilder7. I marked that TomCat close connection 
during PDF download process ; TomCat consolle show the following message

"java.net.SocketException: Connection aborted by peer: socket write error"

TomCat lose connection and reopen socket stream; the result is a new call to
servlet 

someone hnow why happen this?

Regards 
Below is the text of a simple servlet that creates a PDF that
works great in Acrobat Reader for IE.


import java.io.*;
import javax.servlet.*;
import javax.servlet.http.*;
import com.lowagie.text.*;
import com.lowagie.text.pdf.PdfWriter;

public class PDFTest extends HttpServlet
{
   public void doGet(HttpServletRequest request,
      HttpServletResponse response) throws ServletException, IOException
   {
      OutputStream out = response.getOutputStream();
      ByteArrayOutputStream baos = new ByteArrayOutputStream();
      try
      {
         Document document = new Document(PageSize.LETTER, 0, 0, 0, 0);
         PdfWriter.getInstance(document, baos);
         document.open();
         Phrase companyPhrase = new Phrase("My Company, Inc.",
            new Font(Font.TIMES_NEW_ROMAN, 8));
         Paragraph companyPara = new Paragraph(companyPhrase);
         companyPara.setAlignment(Paragraph.ALIGN_CENTER);
         document.add(companyPara);
         document.close();
         response.setContentType("application/pdf");
         response.setContentLength(baos.size());
         response.setBufferSize(baos.size());
         baos.writeTo(out);
         out.flush();
      }
      catch (Exception e)
      {
         System.err.println(e.toString());
      }
      finally
      {
         out.close();
      }
   }
}
Gaetano Russo
System Engineer




-------------------------------------------------------
This SF.NET email is sponsored by:
SourceForge Enterprise Edition + IBM + LinuxWorld = Something 2 See!
http://www.vasoftware.com
_______________________________________________
iText-questions mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/itext-questions

Reply via email to