Issue
What is the difference on using response.setContentType("application/octet-stream");
instead of response.setContentType("text/csv");
for setting content type for a csv file, it seems they both produce the same result. Which method is preffered more? Just curious.
Solution
Some browsers, particularly IE, completely ignore the content type header, and open the response in an application according to the file extension. In those browsers, it probably doesn't matter.
However, text/csv is the preferred content type, and should work properly with all browsers. "application/octet-stream" is very generic, and does not give any hint as to what type of application should be used to open the result.
If you were returning an MS Excel file, for instance, you would use application/vnd.ms-excel to be more specific. Since CSV is not tied to one particular application, text/csv is preferred.
Answered By - GreyBeardedGeek
Answer Checked By - Mildred Charles (JavaFixing Admin)