I have String that contains xml data like :
String strXml = "<?xml version=\"1.0\" encoding=\"UTF-8\"?> <Name> sample <name> ";
I want to download the string strXml as XML file. Below code open the xml file instead of downloading it.
PrintWriter out=response.getWriter();
out.write(strXml );
Please suggeest how to download the data in string strXml as XML file.
You are talking about file download from web site? You should write following response headers:
Content-type: application/octet-stream
Content-Disposition: attachment; filename=filename.xml
then you can just out.print(strXml)
with a content of the file. Browser will ask a user to download filename.xml