you may want to do something for your exception - at least write to stdout to indicate you got an error. If you get an exception thrown, you have not written anything to the response, therefore you will get a blank screen.
Charlie
> -----Original Message-----
> From: Chris Gross [mailto:[EMAIL PROTECTED]]
> Sent: Monday, July 09, 2001 9:42 AM
> To: tomcatlist
> Subject: streaming pdfs through servlet...
>
>
>
> 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() {
> }
> }
>