• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

Writing out Binary Data via CFScript

New Here ,
Mar 26, 2008 Mar 26, 2008

Copy link to clipboard

Copied

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.

TOPICS
Advanced techniques

Views

596

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Valorous Hero ,
Mar 26, 2008 Mar 26, 2008

Copy link to clipboard

Copied

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.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Mar 27, 2008 Mar 27, 2008

Copy link to clipboard

Copied

Thank you for your reply - yes I did come across that TechNote - unfortunately to refers to a previous 'Updater' version [4]

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Valorous Hero ,
Mar 27, 2008 Mar 27, 2008

Copy link to clipboard

Copied

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.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Mar 27, 2008 Mar 27, 2008

Copy link to clipboard

Copied

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 🙂

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Valorous Hero ,
Mar 27, 2008 Mar 27, 2008

Copy link to clipboard

Copied

LATEST
Yes, a new updater would definitively be a last resort ;-) Cfcontent should do the trick.

Best of luck

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Resources
Documentation