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 river on April 11, 2001 at 3:09 PM

I have no problem for using the following java code in my *serlvet; however, I do have problem for my previous window keeps running after the download completed and pop-up window clsoed. Any ideals ?

my JAVA code:
// set response header
"attachment; filename=" + lstrSvcName + lstrSvcNo + "V" + lstrSvcVersion + user.getLogin()+ lstrDate + "." + lstrSvcType.toLowerCase() + ";");

- River

> 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
> code a servlet to download dynamically created data (unique) to each person, so that it will work in almost any browser, please let me know.

> 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
> only you never got the save-as pop-up

> see:

> How many times can this be coded wrong in the browser?

> Thanks!

> > 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
> > complete?

> > Pls. reply asp.

> > Thanks
> > -Raj

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