| Author |
Want DynamoServlet response as csv
|
Dylan Salmon
Greenhorn
Joined: Nov 30, 2012
Posts: 2
|
|
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
|
 |
Bear Bibeault
Author and ninkuma
Marshal
Joined: Jan 10, 2002
Posts: 56204
|
|
|
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.
|
[Smart Questions] [JSP FAQ] [Books by Bear] [Bear's FrontMan] [About Bear]
|
 |
Paul Clapham
Bartender
Joined: Oct 14, 2005
Posts: 16483
|
|
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
Joined: Nov 30, 2012
Posts: 2
|
|
|
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
Bartender
Joined: Oct 14, 2005
Posts: 16483
|
|
The correct way to produce this header
Content-disposition: attachment; filename=fname.ext
is
|
 |
 |
|
|
subject: Want DynamoServlet response as csv
|
|
|