Problem while displaying cewolf images

Spocke
2008-10-07
2013-01-13
  • Spocke

    Spocke - 2008-10-07

    Hi,

    I have a requirement wherein, i need to have a Web client (say c) from which i can view reports from my two individual applications (say A and B). All i will doing is to request for data from "A" and "B" via ajax and display the response in "C".

    I have almost completed, but when the response from A or B contains image (which have been generated using cewolf taglib) then, i would save the image locally and display them (since path are relative).

    I have no problem in saving the images, but when displaying them, i get a sometimes StreamCorruptedException. Below is the stack trace for the same,

    java.io.StreamCorruptedException
    at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1326)|
    at java.io.ObjectInputStream.defaultReadFields(ObjectInputStream.java:1912)|
    at java.io.ObjectInputStream.readSerialData(ObjectInputStream.java:1836)|
    at java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:1713)|
    at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1299)|
    at 
    java.io.ObjectInputStream.readObject(ObjectInputStream.java:339)|
    at de.laures.cewolf.storage.FileStorage.getChartImage(FileStorage.java:98)|
    at
    de.laures.cewolf.CewolfRenderer.doGet(CewolfRenderer.java:133)|

    Following is the code i am using to save the image,

    URL url = new URL("http://<hostname>:<port>/<application name>/<image name>");
    DataInputStream dIn = new DataInputStream(url.openStream());
    DataOutputStream dOut = new DataOutputStream( new FileOutputStream( new File("<file name>")));
    byte[] toRead = new byte[1024];
    while( dIn.read( toRead ) != -1 )
    {
           dOut.write(toRead);
    }
    //flush & close the streams.

    Please let me know why I am getting this exception and how to overcome this.

    Thanks in advance,
    -S-

     
    • Ulf Dittmer

      Ulf Dittmer - 2008-11-07

      At what point is that exception thrown? If I understand it correctly, you're saving the image to disk, and the exception is thrown in some Java code you've written that later displays it? How does it do that, and what role does cewolf play in that?

       

Log in to post a comment.

Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:

JavaScript is required for this form.





No, thanks