• 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

OPEN/SAVE popoup box comes twice

 
Ranch Hand
Posts: 47
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,
I am trying to open a csv file on the browser. I am facing the following problem :

WHen i click on the link that opens the csv file, it popups a window asking whether to OPEN /SAVE the file. If I click on OPEN, instead of opening the file, it again opens the same dialog box. On clicking the OPEN for the second time, it opens the file in excel.

I want the use to see the file only be clicking OPEN button for the first time.

The code snippet is as under:

File file = new File (fileName);
FileInputStream fileStream = null;
try
{
// Open the file to download
fileStream = new FileInputStream (file);
// Read the contents of the disk file into an in memory byte array
int numberOfBytes = fileStream.available ();
byte contents [] = new byte [numberOfBytes];
fileStream.read (contents);
ServletOutputStream out = res.getOutputStream();
res.setContentType(contentType);

res.setHeader("Content-Disposition","attachment;filename=\"" + downloadFileName + "\";");


out.write (contents);
out.flush ();

I AM USING STRUTS FRAMEWORK.

Thanks in advance,
rakesh
 
author & internet detective
Posts: 41860
908
Eclipse IDE VI Editor Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Rakesh,
It's not a problem with your code. This happened to us using Windows 2000, but not Windows XP with the same code. It probably has to do with browser/operating system settings.
 
Rakesh Gadre
Ranch Hand
Posts: 47
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

Thanks for the reply. I am using Windows XP. The application uses struts. Wil that make any difference ? If i try the same code seperately using a jsp file directly, it works properly..

I am really stuck up it seems :roll:

Rakesh
 
Bartender
Posts: 4121
IntelliJ IDE Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I'll transfer this to the Struts forum and see if anyone has run into this before...
 
reply
    Bookmark Topic Watch Topic
  • New Topic