I am trying to send a plain text document (don't ask why) to the browser from a servlet. I set the content type to text/plain but it always prompts me to save the file. Shouldn't plain text just display in the browser window?
Yeah, should do. Have you tried setting the filename to so it has a .txt extension? response.setHeader("Content-Disposition","attachment; filename=test.txt");
Sometimes it make a difference though, based on browsers trying to be too intelligent with incomming file types.
I hate IE!!! OK, I found the problem and the cure... It seems that if the text file is too big (not sure what "too big" is yet) then IE will not display it in the browser even if you identify it as a text file. But there is a workaround. I send a single new line character and then flush. Then I send the rest of the file. It seems that receiving the single character commits IE to displaying as text.
After all that, the users changed their minds and decided they would prefer to be prompted to save the file. This works to do that in IE: response.setHeader("Content-Disposition","attachment; filename=test.txt");
Post by:autobot
Skool. Stay in. Smartness. Tiny ad:
a bit of art, as a gift, the permaculture playing cards