The Artima Developer Community
Sponsored Link

Legacy Java Answers Forum
September 2000



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.



Posted by Raj on January 13, 2001 at 1:49 AM

Hello there,
i am facing some wired problem similar tio this.
I;ve used res.setHeader("Content-Disposition","attachment; filename=\"" + filename + "\";")

And i am using IE5.5 , When download dialog pops up, and choose
to save as, i do not get filename which was specified. Rather get
current webpage file name, but choosing to open twice and third
click to save as it gets right filename

my question is, is there anything wrong with browser or
i am not writting routine properly if so can you pls. just
list the steps? Do i have to close the stream when write is

Pls. reply asp.


> Hi krnbhaskar,

> 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.


Salil V Gangal


Sponsored Links

Copyright © 1996-2009 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use - Advertise with Us