Posted By:
Scott_Oliver
Posted On:
Wednesday, April 17, 2002 11:56 AM
I need to intercept some HTML output generated by a call to a 3rd party appliction. The original call took as a parameter an output stream object like this: ...... renderMenuBar(new PrintWriter(out), ..... As a solution to a previous problem (where I just wanted to make the output disappear), someone suggested replacing the "new PrintWriter(out)" parameter with one providing a ByteArrayOutputStream object, like this: ByteArrayOutputStream bitBucket = new java.io.ByteArrayOutputStream(10000); ...... renderMenuBar(new PrintWriter(bitBucket ), ..... That worked great, and I believed it would solve my current problem as well; I could just use bitBucket.toByteArray
More>>
I need to intercept some HTML output generated by a call to a 3rd party appliction. The original call took as a parameter an output stream object like this:
...... renderMenuBar(new PrintWriter(out), .....
As a solution to a previous problem (where I just wanted to make the output disappear), someone suggested replacing the "new PrintWriter(out)" parameter with one providing a
ByteArrayOutputStream object, like this:
ByteArrayOutputStream bitBucket = new java.io.ByteArrayOutputStream(10000);
...... renderMenuBar(new PrintWriter(bitBucket ), .....
That worked great, and I believed it would solve my current problem as well; I could just use bitBucket.toByteArray() or bitBucket.toString() and manipulate the HTML to my hearts content. Unfortunately, no.
That plan works fine except for one small problem: I'm only seeing the first 8k of the output (bitBucket.size() returns 8192).
This is in a JSP environment, so one of the first things I tried to do was change the buffer size through the JSP "page buffer=20kb" directive but that didn't help. I also tried calling the toByteArray() method twice to see if it would grab the next buffer, but that just gave me the same output. I've tried allocating the ByteArrayOutputStream object with the default size and let it grow and with a specific size (10k); in both cases all I get are 8192 bytes.
How can I retrieve the subsequent buffers?
This is a rather crucial problem for me to resolve, so any advice or suggestions would be most appreciated!
-Scott
<<Less