Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Java > Java Servlet not displaying PDF/ZIP files correctly in IE

Reply
Thread Tools

Java Servlet not displaying PDF/ZIP files correctly in IE

 
 
Paul Jacobs
Guest
Posts: n/a
 
      08-23-2003
We have had a Java servlet running in a production web application for
a few years that will read a PDF, text, or zip file located outside
the scope of the web site (Note: this is running on solaris).
Everything was working great until the spring when Microsoft started
releasing a ton of security patches for both IE and windows.

Text files are still working, but users can no longer view the ZIP or
PDF files within IE. Depending on which patches the user has applied
to their computers, when trying to view a pdf inside IE their will be
a white screen in IE, acrobat will start and give some errors, and
other similar variations. For the zip files, Winzip will start up and
you can see in the status bar that it is downloading the file, but
when it finishes you have an empty zip.

If users save the files to their computers or network, they can open
the zips or pdfs without any problems. The servlet must be streaming
the binary data fine if it saves properly to a filesystem, but there
must be something that is throwing IE off.

Here is a snippet of code from the servlet using a PDF as an example.
Any help would greatly be appreciated. Most of our users are on IE 6.
I think everything works fine in Netscape 6.2, but haven't tried
other versions or Mozilla.

servet code:

File f = new File("/reports/report.pdf");

response.setContentType("application/pdf") ;
response.setHeader("Content-Disposition", "inline;
filename=report.pdf");

//I have tried it with and without the next two lines of code
//if this is not the proper way to determine content length,
//please post the correct code
int length = (int)(f.length());
response.setContentLength(length);

FileInputStream fis = null;
try{
fis = new FileInputStream(f);
//OutputStream out;
DataOutputStream outputStream = new
DataOutputStream(response.getOutputStream());
byte[] buf = new byte[4 * 1024]; // 4K buffer
int bytesRead;
while ((bytesRead = fis.read(buf)) != -1) {
outputStream.write(buf, 0, bytesRead);
}
} finally {
if (fis != null) fis.close();
}

Thanks.
Paul
 
Reply With Quote
 
 
 
 
Darren Davison
Guest
Posts: n/a
 
      08-23-2003
Paul Jacobs wrote:

> Text files are still working, but users can no longer view the ZIP or
> PDF files within IE. Depending on which patches the user has applied
> to their computers, when trying to view a pdf inside IE their will be
> a white screen in IE, acrobat will start and give some errors, and
> other similar variations.


this may be of use to you: <http://www.lowagie.com/iText/faq.html#msie>

Regards,

--
darren@ public key
davison|uk.net www.davison.uk.net/key.jsp
 
Reply With Quote
 
 
 
 
Paul
Guest
Posts: n/a
 
      08-24-2003
Thanks, but I am not sure how much that is going to help. The link you gave
me mostly is talking about dynamically generating a PDF in a ByteArray and
displaying it. In my case the PDFs already exist, so instead of reading
from a ByteArray I am reading from a file.

Anyone else have any idea on how to fix the issue I am having with the
servlet?

Paul

"Darren Davison" <> wrote in message
news:3f47e339$0$190$ t...
> Paul Jacobs wrote:
>
> > Text files are still working, but users can no longer view the ZIP or
> > PDF files within IE. Depending on which patches the user has applied
> > to their computers, when trying to view a pdf inside IE their will be
> > a white screen in IE, acrobat will start and give some errors, and
> > other similar variations.

>
> this may be of use to you: <http://www.lowagie.com/iText/faq.html#msie>
>
> Regards,
>
> --
> darren@ public key
> davison|uk.net www.davison.uk.net/key.jsp



 
Reply With Quote
 
Neomorph
Guest
Posts: n/a
 
      08-25-2003
On Sun, 24 Aug 2003 16:21:01 GMT, "Paul" <>
two-finger typed:

>Thanks, but I am not sure how much that is going to help. The link you gave
>me mostly is talking about dynamically generating a PDF in a ByteArray and
>displaying it. In my case the PDFs already exist, so instead of reading
>from a ByteArray I am reading from a file.


Then you missed the part about making sure that the headers that are sent
back by the Servlet contain the exact length of that file ?

I read the comments on the page referred, and it looks like a missing or
inaccurate Content-length header can keep MSIE from displaying the PDF file
properly.

>
>Anyone else have any idea on how to fix the issue I am having with the
>servlet?


The solution was right there.

>
>Paul
>
>"Darren Davison" <> wrote in message
>news:3f47e339$0$190$ et...
>> Paul Jacobs wrote:
>>
>> > Text files are still working, but users can no longer view the ZIP or
>> > PDF files within IE. Depending on which patches the user has applied
>> > to their computers, when trying to view a pdf inside IE their will be
>> > a white screen in IE, acrobat will start and give some errors, and
>> > other similar variations.

>>
>> this may be of use to you: <http://www.lowagie.com/iText/faq.html#msie>
>>
>> Regards,
>>
>> --
>> darren@ public key
>> davison|uk.net www.davison.uk.net/key.jsp

>


Cheers.
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Word documents not displaying correctly in link tshad ASP .Net 0 02-16-2007 12:41 AM
Tk not displaying correctly Tuvas Python 2 12-22-2005 02:28 AM
Re: HELP!!! ASP.NET pages not displaying correctly Raterus ASP .Net 1 06-05-2004 05:20 PM
Servlet question(Tomcat, web.xml, servlet-class, servlet-name) circuit_breaker Java 2 04-04-2004 03:26 AM
intranet site not displaying correctly on subnet Jim PKP Computer Support 0 01-15-2004 09:48 PM



Advertisments