tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Peter Hrastnik <peter.hrast...@1012surf.net>
Subject Re: streaming pdfs through servlet...
Date Mon, 09 Jul 2001 13:58:44 GMT
I had a similar problem in a php project in the past. There are
browser/acrobat-plugin combinations that cause strange behaviour when
passing through a pdf stream. 
Try using some other browser/acrobat combinations to track your problem
down. If another combination works, you know that your jsp code is
basically ok.

Bye,
	Peter.


-- 
Mag. Peter Hrastnik
tele.ring Telekom Service GmbH
A-1030 Wien, Hainburgerstr. 33
Tel.: +43/1/931012/3277, Mobil: +43/650/6503277



Chris Gross wrote:
> 
> This is my first post to this list.  Hi.
> 
> I've written a quick little servlet to stream pdf files from my database to
> the browser but I'm encountering a strange little problem.  The first time I
> call the servlet the page loads (I can see adobe's little plugin
> initializing) but nothing ever displays.  All I see is a whitespace in the
> browser.  But if I then immediately hit the refresh button then the pdf
> shows up.  Has anyone ever seen anything like this before?  I'm not even
> sure where the problem lays, i.e. with the plugin, with the browser, with
> tomcat, or with my servlet.
> 
> Adobe plugin version 5
> IE version 5.5
> 
> Thanks,
> Chris
> 
> ps. Here's my servlet.
> 
> package com.chessys.trecs;
> 
> import javax.servlet.*;
> import javax.servlet.http.*;
> import java.io.*;
> import java.util.*;
> import java.sql.*;
> 
> public class ReportManager extends HttpServlet {
>   private static final String CONTENT_TYPE = "application/pdf";
>   /**Initialize global variables*/
>   public void init() throws ServletException {
>   }
>   /**Process the HTTP Get request*/
>   public void doGet(HttpServletRequest request, HttpServletResponse
> response) throws ServletException, IOException {
>     response.setContentType(CONTENT_TYPE);
>     ServletOutputStream out = response.getOutputStream();
> 
>     Connection dbConnection = (Connection) request.getSession(
> false ).getAttribute( "chesapeake_database_connection");
> 
>     try {
>       Statement stmt = dbConnection.createStatement();
> 
>       ResultSet rs = stmt.executeQuery("Select PDFImage from reportsinpdf
> where reportid = " + request.getParameter("id"));
> 
>       if (rs.next()) {
>         byte [] pdf = rs.getBytes(1);
>         out.write(pdf);
>         out.flush();
>       }
> 
>     } catch (Exception e) {
>       //Yeah i should probably do something here
>     };
> 
>     out.close();
>   }
> 
>   public void doPost(HttpServletRequest request, HttpServletResponse
> response) throws ServletException, IOException {
>     doGet(request,response);
>   }
>   /**Clean up resources*/
>   public void destroy() {
>   }
> }

Mime
View raw message