• 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

Want DynamoServlet response as csv

 
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello, If you can please assist me, I have a public class CSROrderReportLookup extends DynamoServlet. Even when I change the response to CSV the string gets printed to the page instead of prompting for a download. The code I am using is as follows:

PrintWriter fileWriter = null;
response.setContentType("application/csv");
response.setHeader("content-disposition", "filename=test.csv");

fileWriter = response.getWriter();
fileWriter.append("Hello");
fileWriter.flush();

I have a working example of another page that extends GenericFormHandler instead of DynamoServlet which creates a download instead of printing to the page. But I would like to do it from DynamoServlet if at all possible. Can you give me an example of what I may need to change to get it to work?

Thanks,

Dylan
 
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
I looked up DynamoServlet and it appears to be a component of the Oracle ATG commerce platform. I've moved this post to a more appropriate location.
 
Marshal
Posts: 28193
95
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Dylan Salmon wrote:Even when I change the response to CSV the string gets printed to the page instead of prompting for a download. The code I am using is as follows:

PrintWriter fileWriter = null;
response.setContentType("application/csv");
response.setHeader("content-disposition", "filename=test.csv");



That's because the browser which you tested on is configured to do that when it gets files with that MIME type. Here's a link to a help page which addresses how to force a download: How To Raise a "File Download" Dialog Box for a Known MIME Type.

And, welcome to the Ranch!
 
Dylan Salmon
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thank you for your response Paul, however changing adding content-disposition: attachment to response.setHeader("content-disposition: attachment", "filename=test.csv"); has not resolved the issue, the string is still printing inline and not as a file download. Do you have any other suggestions?
 
Paul Clapham
Marshal
Posts: 28193
95
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The correct way to produce this header

Content-disposition: attachment; filename=fname.ext



is


 
reply
    Bookmark Topic Watch Topic
  • New Topic