Sachin J
Sachin J

Reputation: 2191

How to download xml file from server in IE using Java?

I have to download a xml file from server using IE browser.

response.setContentType("application/octet-stream");
       response.setHeader("Content-Disposition", "attachement; filename=xyz.xml");

Its working fine for other browsers, but in IE it shows xml output on browser.

How can I fix it? Please, help :) thanks

Upvotes: 2

Views: 2426

Answers (1)

Muhammad Imran Tariq
Muhammad Imran Tariq

Reputation: 23352

I think your Content-type is wrong. You need to set all these headers. It works for me in all browsers.

response.setHeader("Pragma", "public");
response.setHeader("Expires", "0");
response.setHeader("Cache-Control", "must-revalidate, post-check=0, pre-check=0");
response.setHeader("Content-type", "application-download");
response.setHeader("Content-Disposition", "attachment; filename=" + fileName);
response.setHeader("Content-Transfer-Encoding", "binary");

Upvotes: 3

Related Questions