Hi, all,

My browser is MSIE 5.0 and i try to run following servlet on tomcat but still get blank window. is there anybody give me a hand? thanks

 

import java.io.PrintWriter;
import java.io.IOException;
import java.io.ByteArrayOutputStream;
import java.io.File;

import java.util.Date;

import javax.servlet.http.*;
import javax.servlet.*;

import com.lowagie.text.*;
import com.lowagie.text.pdf.PdfWriter;
import com.lowagie.text.html.HtmlWriter;

public class Chap0105 extends HttpServlet {
   
    public void doGet (HttpServletRequest request, HttpServletResponse response)
    throws IOException, ServletException {
       
        // we retrieve the presentationtype
        String presentationtype = request.getParameter("presentationtype");
       
        // step 1
        Document document = new Document();
        try {
            // step 2: we set the ContentType and create an instance of the corresponding Writer
            response.setContentType("application/pdf");
    ByteArrayOutputStream ba = new ByteArrayOutputStream();
    PdfWriter.getInstance(document, ba);
            document.open();
   document.add(new Paragraph("Hello world"));
    response.setContentLength(ba.size());
    ServletOutputStream out = response.getOutputStream();
    ba.writeTo(out);
    out.flush();
        }
        catch(DocumentException de) {
            de.printStackTrace();
            System.err.println("document: " + de.getMessage());
        }
       
        // step 5: we close the document (the outputstream is also closed internally)
        document.close();
    }
}



Do you Yahoo!?
Faith Hill - Exclusive Performances, Videos, & more
faith.yahoo.com

Reply via email to