Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Writing byte data through jsp

 
Chris Reeves
Ranch Hand
Posts: 95
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I need to return a file to the browser through a jsp. The file contains binary data, so I need to return bytes.
Here's the catch: I'm writing the jsp to run under coldfusion mx. So, while I would normally call getOutputStream, I encounter a java.lang.IllegalStateException when calling getOutputStream. This means that getWriter has already been called.
So, I'm stuck with a writer, trying to write bytes. The writer is happy to write the bytes (which return as integers), or I can convert them to char.
This output is close to the original, but doesn't product the file I'm returning exactly. I blame this on the character encoding used by the Writer.
Any suggestions on how to coerce the writer to write bytes without any encoding? Or other ideas? I'm stuck with the writer, as coldfusion seems to take care of that on its own.
Thanks!
Chris
 
Andy Bowes
Ranch Hand
Posts: 171
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Chris,
I think you will need to use a servlet rather than a JSP page to send a binary file back to clients browser. I don't know the ColdFusion MX architecture, is that feasible ?
 
Chris Reeves
Ranch Hand
Posts: 95
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Andy, you took the words right out of my mouth.
I am going to try it with a servlet - I know that will work.
But, if anyone else has any ideas, please chime in.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic