Win a copy of Cross-Platform Desktop Applications: Using Node, Electron, and NW.js this week in the JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

.csv files are opend in the same browser withour displaying the download dialog box.  RSS feed

 
sheetal pathak
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
In our web based application we are using windows XP SP-2 and IE 6.0
When the user clicks on the link related to CSV File generation, the generated file is directly displayed in the browser, from where its link was clicked, with prompting the user with the download dialog box as to whether he wish to "Open" the file or "Save" it.

The function which takes care of the download is as below :-

.
.
.
response.setContentType(strContent);
if (strFileType.equals(LCConstants.ACTION_XML))
{//if it is XML
response.setHeader("Content-Disposition",
"attachment;filename="+strFileName+".xml");
out = response.getOutputStream();
}
else
{//if it is CSV
response.setHeader("Content-Disposition",
"inline;filename="+strFileName+".csv");
out = response.getOutputStream();
}
out.println(strXMLOrCSV);
ByteArrayOutputStream byteStream=new ByteArrayOutputStream();
byteStream.writeTo(out);
byteStream.flush();
byteStream.close();
}//end of download()

The above code works fine for windows 2000.
If in the above code "inline" is changed to "attachment" then, it works fine in windowz XP but in window 2000 it pops up the download dialog box twice.

While I know about the "Confirm open after download" and "Browse in same
window" options that I can set for the file types,
is there any way to force IE to always ask to Open/Save a file, regardless of the extension?

can abody plz share their knowlegde with me.
Thank you.
Regards,
Sheetal...
 
Jeanne Boyarsky
author & internet detective
Marshal
Posts: 37180
515
Eclipse IDE Java VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Sheetal,


Notice that the xml one is set to "attachment" and the csv one is set to "inline." This is what is causing one to be downloaded (like an attachment) and one to be displayed in the browser (inline.) Switching the cvs one to attachment will give you the desired behavior.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!