-
I am facing error while saving the file from the browser to the client side.
I have an xml data that is created by a servlet. I have to give download option to the user. The dialog box is comming but when i am saving it is giving me following error:
"Internet Explorer was not able to open this Internet site. The requested site is either unavailable or cannot be found. Please try again later."
I am setting the following response header in the servlet.
sponse.setContentType("application/xml");
response.setHeader("Content-Disposition", "attachment; filename=\""
+ "filename.xml\"");
-
Your response headers look fine.
Where are you copying your XML data into the response?
It should look like this:
//spring
//org.springframework.util.FileCopyUtils
String text = " ";
//... ur code
response.setContentLength(text.getBytes().length);
FileCopyUtils.copy(text.getBytes(), response.getOutputStream());
//non-spring
response.setContentLength(text.getBytes().length);
//.. ur code
ServletOutputStream sos = response.getOutputStream();
sos.write(text.getBytes());
sos.flush();
sos.close();
Hope this helps,
K8
-
See for example Download servlet in JSOS:
http://www.servletsuite.com/servlets.htm
-