Hi In below script I used ("application/vnd.ms-excel") and ("application/msword"). But none is working. I mean it is showing in as plain text. It is not showing in Word or excel. Do I need to do some parameter setup or any thing.
Actually, I don't think it would be appropriate for yamini to use getOutputStream().
He (she?) is attempting to write a text file (tab delimited). Excel can open this file as a spreadsheet.
But you cannot put formulas into a tab delimited file. Or at least, if you do they don't come out as formulas in the spread sheet. The spreadsheet will show the forula '=SUM(B2:C2)' in a cell as though it were a string -- which is the only thing you can put into a tab delimited file for Excel.
In above even I set content type as excel, if I set header as .doc then it is opening data in MS Word. It is contradictory. ---- below 3 and 4 codes causing output to open in MS Word. is it mean setContentType is not considered if Content-Disposition value is present. (3) //response.setContentType("application/vnd.ms-excel"); response.setHeader("Content-Disposition", "attachment; filename=myfile.doc");
Internet Explorer is smart enough to work without providing content type. It uses the file extension and/or contents of the file to determine the content type. Also, this behaviour is inconsistent with the different versions of Internet Explorer and Windows Operating System. Netscape does expect you to provide content type. So it is a good practise to use response.setContentType always.
will open in the document in the same browser window.