Skip to main content
Known Participant
March 26, 2008
Question

Writing out Binary Data via CFScript

  • March 26, 2008
  • 4 replies
  • 705 views
Hopefully someone will be able to provide some insight or possible resolution to this:

On a site I'm now managing there is a piece of code that is being used to write out binary data (images) to the client that are located on the HDD. This code (after doing some searching) is verbatim from Christian Cantrell's blog posting from about 5 years ago ( Using ColdFusion to Write out Binary Data).

As far as I can tell the end user is not experiencing any problems - but the exception.log (as well as the application.log) is filling up with the following error:

java.lang.IllegalStateException
at jrun.servlet.JRunResponse.getOutputStream(JRunResponse.java:179)

(Hopefully the actual code in question is posted at the bottom of this message)

Of course if the end users are not getting an error this is fine, but it doesn't reflect well on us when the client decides to look at the log files and sees and endless stream of error messages related to this code.

I have tried using the reponse.reset(); in a couple of different locations within that 'script' but this in turn generates teh following error:

java.lang.IllegalStateException: Response has already been committed
at jrun.servlet.jrpp.ProxyEndpoint.resetBuffer(ProxyEndpoint.java:991)

I've searched and read every possible link I could google and nothing else seems to provide any insight on a solution.

The client is currently running CFMX 7.0.2 (no hot fixes) standard edition ... which seems to be utilizing JRun Updater 5.

Thanks in advance for any possible insight or fix.

This topic has been closed for replies.

4 replies

Inspiring
March 27, 2008
Yes, a new updater would definitively be a last resort ;-) Cfcontent should do the trick.

Best of luck
stsemrauAuthor
Known Participant
March 27, 2008
Yes - I'm not sure if I can even apply the JRun Updaters at this point and I agree - I'm going to recommend changing from the <cfscript to using the <cfcontent. It's cleaner and saves about 12 lines of code :)
stsemrauAuthor
Known Participant
March 27, 2008
Thank you for your reply - yes I did come across that TechNote - unfortunately to refers to a previous 'Updater' version [4]
Inspiring
March 27, 2008
Yes. The mention of 7.0.2 using updater 5 did not sound defintive. I was not sure which version it used myself. So I thought I would mention the TechNote just in case.

However, I realized the code must have been written for MX6. MX7 introduced the "variable" attribute of the cfcontent tag. That attribute can contain binary. So you should be able to use cfcontent instead.

Inspiring
March 27, 2008
I am not very familiar with servlets, but did you come across this TechNote that describes a similar error?

http://kb.adobe.com/selfservice/viewContent.do?externalId=28c3e2c2&sliceId=2

ssemrau wrote:
> out.close();

I may be 100% wrong here, but I seem to recall reading that you should not close the output stream of a servlet.