Streaming files to Firefox



I have some simple code that reads a file from disk and streams it to a web
browser.

The servlet container is Tomcat 5.0.28
IE 6.0.3790
Firefox 1.0.3

This works for IE, but not Firefox:

ServletOutputStream out = res.getOutputStream();
File testFile = new File("C:/temp/MyTestPDF.pdf");

res.setHeader("Content-Type","application/pdf");
res.setHeader("Content-Length","4230364");
res.setHeader("Content-Disposition", "inline;
filename=\"MyTestPDF.pdf");

int bufferSize;
byte[] buffer=new byte[2048];
FileInputStream fis=new FileInputStream(testFile);
while( (bufferSize=fis.read(buffer)) != -1)
out.write(buffer, 0, bufferSize);
out.close();


Now, if I change the Content-Disposition to this:
res.setHeader("Content-Disposition", "attachment;
filename=\"MyTestPDF.pdf");
Both browsers correctly prompt me to open or download the file.

I want the file to stream (eventually into a new window) without being
prompted.
Any help is greatly appreciated!






.



Relevant Pages

  • Re: Streaming files to Firefox
    ... I'd expect the behavior to be client-dependent based on the browser ... > I have some simple code that reads a file from disk and streams it to ... but not Firefox: ... > Both browsers correctly prompt me to open or download the file. ...
    (comp.lang.java.programmer)
  • RE: XP sp2, IE, address bar does not update, c#
    ... string filename = System.IO.Path.GetFileName; ... The following problem is XP sp2 specific. ... The text file content streams back to the browser just fine and the content ...
    (microsoft.public.inetsdk.programming.webbrowser_ctl)
  • Re: No RealPlayer no more?
    ... Jaimie Vandenbergh wrote: ... Doesn't work with streams though, ... Hurm. ... Which browser do you use? ...
    (uk.comp.homebuilt)
  • Re: No RealPlayer no more?
    ... Trevor Best wrote: ... Doesn't work with streams though, ... Hurm. ... Which browser do you use? ...
    (uk.comp.homebuilt)
  • Re: asx will not stream
    ... > Streams great on PC's...Will not stream on Mac's even with ... It just opens the asx text in the browser. ... MVP: http://mvp.support.microsoft.com/ MVPs.org: http://www.mvps.org/ Retirez NoSpam de mon adresse pour m'écrire/Remove NoSpam to e-mail me ...
    (microsoft.public.windowsmedia.player.mac)