• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Bear Bibeault
  • Junilu Lacar
  • Jeanne Boyarsky
  • Tim Cooke
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • salvin francis
  • Frits Walraven
  • Scott Selikoff
  • Piet Souris
  • Carey Brown

Download file without getting a "File Download" prompt from IE.

Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have some java code in a servlet that generates an "xyz file" an sends it to the browser. I want IE to open the file in the associated application without prompting for a file download. (IE 6 on Windows XP)

In Windows Explorer I went under - Tools - Folder Options - File Types - scroll down until you find xyz (the extension) - highlight it - Advanced - remove the check in Confirm after Download.

From what I have seen on the web this should work, but the "File Download" dialog box still pops up. I think this is because I am sending the file outside of the response stream. I am doing this so that I don't need to create an actual file that would need to be deleted.

Does anyone have a clever solution to get a file to open on a client PC in the default app without seeing the "File Download" prompt?

Here is a sample of the code generating the file in case that is what the problem is.

private void xyzReport(

javax.servlet.http.HttpServletRequest request,

javax.servlet.http.HttpServletResponse response)

throws IOException, ServletException


response.setContentType("application/octet-stream xyz");

//cvs file in this case

response.addHeader("Content-Disposition", "attachment;filename=\"report.xyz\";");

PrintWriter out = response.getWriter();

out.println("TEXT FILE Generated by servlet");

ActivityReportValue activityReportValue = null;

Vector itemActivity = null;

for (int i = 0; i < 100; i++)


String line = ("text,text,text,text,text");



Ranch Hand
Posts: 5093
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Make sure you set the correct content type, and set it to one which IE recognises as belonging to an application which can work inside the browser (like Excel or Acrobat reader).
You may also have to make sure the filetype ends in the default extension for this filetype (used to need to set the servlet name to something.xls when sending CSV data to be opened by Excel in IE4, might no longer be needed).
Thank you my well lotioned goddess! Here, have my favorite tiny ad!
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
    Bookmark Topic Watch Topic
  • New Topic