Sponsored Link •
This page contains an archived post to the Java Answers Forum made prior to February 25, 2002. If you wish to participate in discussions, please visit the new Artima Forums.
I have exactly the same problem as Brian's having. Does anyone found a good solution yet? If yes, please let us know!
Thanks a lot.
> I also got strange errors trying to download a file from a java servlet using a JSP page.
> There seems to be a bug(s) in IE 5.5 service pack 1; with setting content-disposition attachment; filename=file.qif
> Check out:
> This page identifies the problem in IE 5.5 sp1, and says there is a fix in service pack one. I downloaded the latest IE 5.5 sp1 version, and still have the same problem.
> I do get the file save as pop-up, but the default file name is not what im setting it to; it is picking up the name of the servlet / page, and the data saved is not what the servlet sent; ts the contents of the web page (the actual html code).
> ho hum. If anyone has more insight / info on how to
> Netscaps seems to work fine, but IE works in some versions, and not in othere. IE had a problem almost like this in IE 4.01
> How many times can this be coded wrong in the browser?
> > And i am using IE5.5 , When download dialog pops up, and choose
> > my question is, is there anything wrong with browser or
> > Pls. reply asp.
> > Thanks
> > > I just changed the line from
res.setHeader("Content-Disposition","attachment; filename=\"" + downloadFile + "\";");
> > > to
res.setHeader("Content-Disposition","attachment; filename=\"" + "abc.txt" + "\";");
> > >
Then I ran the servlet using Netscape and IE both and both gave me the correct file name (abc) and correct file type (plain text - Netscape, text document - IE) to save. So my guess is that your program is correct.
> > >
I don't know why it showed you different names, but I'm speculating that perhaps it is because of differnt file extensions getting recognized differently by the browsers. Perhaps you may want to try to hardcode the name the way I did to test out whether Netscape and IE are still behaving differently when extension is .txt or whether they behave differently when some other extension comes into picture.
> > >