0 Replies Latest reply on May 22, 2003 8:37 AM by alex69

    Problem with mime type pdf and jetty

    alex69 Newbie

      This code on WebLogic Server return on the browser the pdf document. With jboss and jetty return a blank page.

      public void doGet(HttpServletRequest request, HttpServletResponse response)
      throws IOException, ServletException
      {

      String doc = request.getParameter("doc");
      Document document = new Document();

      response.setContentType("application/pdf");
      ByteArrayOutputStream out = new ByteArrayOutputStream ();

      try
      {
      PdfWriter.getInstance(document, out);

      }
      catch(DocumentException de) {
      de.printStackTrace();
      System.err.println("document: " + de.getMessage());
      }
      document.open();

      if (doc!=null && doc.trim().length()>0)
      {
      try
      {
      PdfGenerator pdf = (PdfGenerator) Class.forName(doc).newInstance();
      pdf.setRequest(request);
      pdf.setDocument(document);
      pdf.create();
      }
      catch (Exception e)
      {
      e.printStackTrace();
      }
      }



      document.close();
      response.getOutputStream ().write (out.toByteArray ());


      }



      Thanks