• Post Reply Bookmark Topic Watch Topic
  • New Topic

Using ServletOutputStream to write contents to a download file  RSS feed

suresh peter
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

I am using ServletOutputStream and wrapping it with PrintStream (and tried PrintWriter) to write contents to a RTF file that the user downloads. The input for PrintStream is a String text obtained from a database layer. It contains special characters. I am able to create and download the file successfully, but the special characters are not being displayed correctly.

response.setHeader("Content-disposition","file; filename=sample.rtf"); //RTF file being downloaded

ServletOutputStream stream = response.getOutputStream();
PrintStream out = new PrintStream(stream,true,"UTF-8");
out.println("Dear Dr. AuthorŖ: Thank you for"); //Notice the special character in the string


Please suggest how i could handle this issue.

  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!