Hi Tim -

        I've had mixed experiences using servlets to stream files back to
IE.  Mime types aren't recognized, text files are displayed automatically
(w/o the Save dialog being displayed first), etc.  Currently I use this bit
of code to do the job & (most of the time) it does OK.

================
res.setContentLength((int)new File(file.getPath()).length());
res.setHeader("Content-Disposition", "attachment; filename=\"" +
file.getName() + "\""); //see
http://www.ietf.org/rfc/rfc1806.txt?number=1806
res.setContentType("application/octet-stream");

byte[] buffer = new byte[4096];
try
{
        OutputStream out = res.getOutputStream();
        FileInputStream in = new FileInputStream(file.getPath());
        int c;
        while((c = in.read(buffer, 0, 4096)) > -1)
                out.write(buffer, 0, c);
        out.close();
        in.close();
}
catch(IOException e )
{
        e.printStackTrace();
}
================

        It works fine with PDF files & IE 5; not sure about other versions
of IE.

        Best of luck,

Tom

-----Original Message-----
From: Timothy Owen Reilly [mailto:[EMAIL PROTECTED]]
Sent: Tuesday, June 06, 2000 10:09 AM
To: [EMAIL PROTECTED]
Subject: Internet Explorer 5.0 does not handle redirects to pdf files


The company I work for is using a servlet to log requests for documents on
our
site.  The way this works is that the link for the document actually goes
through a servlet I wrote, which logs the request and issues a redirect to
the
"real" url.  This has been working fine, but recently we discovered a
serious
bug involving Internet Explorer and redirects to .pdf files.  If you click
on
the url which goes through the servlet, the browser hangs for a bit, and
then
finally returns "unable to find object to handle request".

Note: This works FINE with all other browsers we've tested.

To test this, I wrote a very simple servlet which only issues a redirect to
a
pdf file we host, and it fails too.  We suspect this is something related to
mime-types, and hence I tried setting the mime-type to "application/pdf"
before
issuing the redirect in the servlet above, but it had no effect and
ellicited
the same behaviour.  Is the <gasp> an IE bug?  Does anyone know of a
workaround?

Platform:
ApacheJServ 1.1.1, ibm jdk 1.18 for Linux, JSDK2.0

Can anyone shed some light on this?

Thanks much,

-Tim

___________________________________________________________________________
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff SERVLET-INTEREST".

Archives: http://archives.java.sun.com/archives/servlet-interest.html
Resources: http://java.sun.com/products/servlet/external-resources.html
LISTSERV Help: http://www.lsoft.com/manuals/user/user.html

___________________________________________________________________________
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff SERVLET-INTEREST".

Archives: http://archives.java.sun.com/archives/servlet-interest.html
Resources: http://java.sun.com/products/servlet/external-resources.html
LISTSERV Help: http://www.lsoft.com/manuals/user/user.html

Reply via email to