Java Mailing List Archive

http://www.junlu.com/

Home » Home (12/2007) » iText »

[iText-questions] Problem on not thread safe servlet

yuanjk

2005-08-15


I had wrote a servlet by using iText ,which seems not thread safe.
Can anybody help me to result this problem.
How can i write a thread safe servle by using iText?

thanks.
---- main servle class ---
public class TestMain extends HttpServlet {
....
public void doGet(HttpServletRequest request,
                          HttpServletResponse response)
    throws ServletException {
          executeTask(request,response);
    }
   
    public void doPost(HttpServletRequest request,
                          HttpServletResponse response)
    throws ServletException {
          executeTask(request,response);
    }
   
    private void executeTask(HttpServletRequest request,
                          HttpServletResponse response)
    throws ServletException {
          String beanname = request.getParameter("beanname");
          BaseBean bb;
          try{
               bb = (BaseBean)Class.forName(beanname).newInstance();  
               bb.doExecute(request,response);
 }catch
....

---- task class ----
public class TestPdf extends BaseBean {
....
  public void doExecute(HttpServletRequest request,
              HttpServletResponse response)
  throws ServletException {
...
 ByteArrayOutputStream baos = new ByteArrayOutputStream();
 PdfDraw ff = new PdfDraw(baos,paramArr);

--- PdfDraw class----
public class PdfDraw {
private com.lowagie.text.Document doc_iText = null;
private com.lowagie.text.pdf.PdfContentByte cb = null;
private Document document = null;
... //use iText to draw pdf to baos


------------------------------------------
ps : thanks for reply to "Why out of memory"
Even thoug xref was kept in memory , by using newPage carefully and
enough memory , now I can create 1000+ page pdf with iText.
Tanks.



-------------------------------------------------------
SF.Net email is Sponsored by the Better Software Conference & EXPO
September 19-22, 2005 * San Francisco, CA * Development Lifecycle Practices
Agile & Plan-Driven Development * Managing Projects & Teams * Testing & QA
Security * Process Improvement & Measurement * http://www.sqe.com/bsce5sf
_______________________________________________
iText-questions mailing list
iText-questions@(protected)
https://lists.sourceforge.net/lists/listinfo/itext-questions
©2008 junlu.com - Jax Systems, LLC, U.S.A.