• 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

Correct Generated File Extensions from Action

 
Ranch Hand
Posts: 81
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
On our application we have to Produce many different csv files.

Right now we are using Strut Actions to produce these files. However, the file extension is always .do (How we have our actions mapped in the web.xml file.) Not very end user friendly.

I just tried to add the mapping of .cvs to the web.xml file and everything worked great, the csv was generated with a nice .csv extension. However, then we tested having a real .csv file on our server and we received a nice "The Requested Resource (blah, blah, blah) is not available."

My question is, how do you go about generating files on demand, but get the correct file extension for them? We are using a lot of csv, xml, and pdf file extensions.

In a different part of our application we actually generate the files and then provide a dynamic link the user so they can download those files from there server. However, we are looking for a solution where we can click the link, generate the data, and have the user save the file all in one shot.

Any ideas?

Thanks for your time,

Nate
 
Sheriff
Posts: 67746
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Investigate usage of the content-type and content-disposition response headers.
 
Nathan Hook
Ranch Hand
Posts: 81
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
From: http://forum.java.sun.com/thread.jspa?messageID=3019572�


Try these lines of code in your action:

response.setContentType("text/csv");
response.setHeader("Content-Disposition", "inline; filename=wibble.csv");



Cheers,
evnafets

 
reply
    Bookmark Topic Watch Topic
  • New Topic