• 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

How to download different files in struits dppending on the file format

 
Ranch Hand
Posts: 85
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I am having two choices in my jsp which allows me to choose a CSV or a PDF to download. I have the files in the respective format on the disk.
I want to put only the required format in the content type so that i can recognize the file while downloading.

If i give response.setContentType("application/pdf");
it works fine for the pdf
but if i set the response.setContentType("application/csv");
it doesn't identify it as a csv file.

WHERE DOES THE PROBLEM LIE?
 
Ranch Hand
Posts: 948
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Here is a link to a listing of registered MIME types: http://www.iana.org/assignments/media-types/

I do not see an "application/csv" but there is a "text/csv" listed. Do you expect the CSV document to open in a spreadsheet program (like Excel)? I don't know if using "text/csv" will do the trick or not.

- Brent
 
Satish Kumar
Ranch Hand
Posts: 85
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
IE doesn't recognise how to open the file when i give it a text/csv format.
It simply prompts for a save dialog instead of the usual OPEN/SAVE dialog.
Does this has something to do with the IE plugin for excel or CSV.
 
Satish Kumar
Ranch Hand
Posts: 85
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
it worked if i give a "application/vnd.ms-excel" type.
But i have same problem of not getting the OPEN button on the open save dialog with the "zip" file format.
 
Ranch Hand
Posts: 4864
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
This is related to the settings you have made for file extensions within Microsoft Windows. If you go into Windows Explorer and define Excel as the porgram to be used for a file extension of .csv, IE will give you the option of opening the file with Excel when you download it.
 
Satish Kumar
Ranch Hand
Posts: 85
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I think i did not write the question right.
I am getting the able to open the CSV file properly. My problem is that if i give Content-type as application/zip for a zip file to be downloaded then it is not recognized by IE or mozilla. it just gives me a save dialog instead of the normal open/save dialog.
 
Merrill Higginson
Ranch Hand
Posts: 4864
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The same principle applies. Unless you have told Windows that you want a file with extension .zip to be opened with a specific program, IE doesn't know how to open it, so the only option it will give you is to save it.

You might try application/x-zip-compressed instead. If you're using IE, This link contains some good information on how it all works.
[ January 01, 2007: Message edited by: Merrill Higginson ]
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic