This week's book giveaway is in the Security forum.
We're giving away four copies of Penetration Testing Basics and have Ric Messier on-line!
See this thread for details.
Win a copy of Penetration Testing Basics this week in the Security forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Using ServletOutputStream to write contents to a download file

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