cocoon-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sh kh <>
Subject Re: Trouble with Dynamic Chart
Date Sat, 08 Aug 2009 23:44:35 GMT
Seems like InputStream is getting converted to string.

Response header from browser:
X-Cocoon-Version: 2.2.0
Accept-Ranges: bytes
Content-Type: image/png
Content-Length: 36
Server: Jetty(6.1.7)

200 OK

The Content-Length: 36 is same as output of System.out.println(is.toString().length()) - where
"is" is InputStream.
I also get a warning at console when starting jetty.
[WARNING] Using platform encoding (Cp1252 actually) to copy filtered resources,
i.e. build is platform dependent!

Not sure if this warning is relevant.

Has anyone encountered similar issue or has a suggestion?

--- On Fri, 8/7/09, sh kh <> wrote:

From: sh kh <>
Subject: Re: Trouble with Dynamic Chart
Date: Friday, August 7, 2009, 11:11 AM

Thanks.  I did look at FINS and may eventually go that way (it needs both data and configuration
in XML format, whereas this approach can work directly with JFreeChart configuration options
and retrieving data directly from database, which is what I'm doing). 

However, I'm still puzzled why InputStream will not be rendered properly.  I also tried getting
chart output as byte array instead of inputstream, and feeding that into map:read...that doesn't
 either.  Perhaps I'm missing some configuration option in reader.....


--- On Fri, 8/7/09, warrell harries <> wrote:

From: warrell
 harries <>
Subject: Re: Trouble with
 Dynamic Chart
Date: Friday, August 7, 2009, 4:32 AM

Have you looked at FINS?

2009/8/6 sh kh <>

I'm following the Cocoon 2.2 tutorial.  I created a dynamic chart with
a java class implementing JFreeChart.  I want to view the rendered
chart in cocoon. I'm using flowscript and map:read, but no luck.  I get
a message saying the image contains errors when viewing src in Firefox
( I tested that the chart does show up fine if I write it to an
external file...I could link to this file but would prefer not to write the chart to the disk). 

I followed the approach from a previous post in the mailing list (

Here is the relevant method to return InputStream in MyClass

public MyClass {

public static InputStream getInputStream() {

(Code to create chart omitted...)

ByteArrayOutputStream out = new ByteArrayOutputStream(); 

JFreeChart chart = ChartFactory.createPieChart("Pie Chart", dataset, true, true, false);
ChartUtilities.writeChartAsPNG(out, chart, 500, 300); 
InputStream is = new ByteArrayInputStream(out.toByteArray());

return is;


function demo() {   
    var inputstream = MyClass.getInputStream();
        {"inputstream": inputstream});



    <map:match pattern="spring-bean">
        <map:call function="demo"/>

   <map:pipeline id="demo-internal" internal-only="true">
      <!-- This pipeline is invoked by the above flowscript. -->
      <map:match pattern="screens/spring-bean">

<!-- doesn't make a difference if I remove type="image" from map:read -->

      <map:read type="image" src="module:flow-attr:inputstream" mime-type="image/png"

Any hints will be appreciated.  Thanks.




View raw message