aspose file tools*
The moose likes JSP and the fly likes Using the out object Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » JSP
Bookmark "Using the out object" Watch "Using the out object" New topic
Author

Using the out object

Sivaraman Lakshmanan
Ranch Hand

Joined: Aug 02, 2003
Posts: 231
Hai all,
I am developing a web application using JSP where I need to display charts dynamically in the page. I use JFreeChart for creating the chart.
After creating the chart object I write it to the browser. This writing is a BuffererdImage Object.
The typical method of JFreeChart I use is
ChartUtilities.writeChartASJPEG(OutputStream,Chart,width,height)
The above method creates a BufferedImage of the chart and write it to the outputstream.
My Problem:
-----------
Everything is fine if I create just one chart object, and it is written to the outputstream. the output stream writes the image to the upper left corner of the browser. If I have more than one chart object and use the same method mentioned above I don't see 2 chart. The first one is just displayed at the upper left corner of the browser. Moverover I don't see any HTML commands I gave in the JSP page.
Where does my other chart object go. or pl tell me how I can write to the browser at a particular location. That is if I have 4 chart objects they should be displayed like a table with 2 rows and 2 cols.
pl give me a soln for the above problem.
Thanks in Advance,
L.Sivaraman.


Regards,
Sivaraman.L
Tim Baker
Ranch Hand

Joined: Oct 04, 2003
Posts: 541
as far as i know you can't write out HTML and an image at the same time. if you want to write out an image you should do this as a seperate jsp/servlet and link it like a normal image in your html for example
<img src='chart1.jsp' />
<img src='chart2.jsp' />
if you really wanted to you might be able to write out both charts as one image and marge them but im guessing that writeChartASJPEG does not support this.
im no expert on images and stuff but i hope this helps. if i'm wrong i'm sure lots of people will correct me


Kim Jong II (North Korea's Dear Leader) said:Nuclear weapons don't kill people, people kill people.
William Brogden
Author and all-around good cowpoke
Rancher

Joined: Mar 22, 2000
Posts: 12769
    
    5
The way to send image data to a browser is with a servlet. JSP are completely oriented to sending text, not binary data. Each resource that goes to make up a page - CSS, JPG, sounds, etc. is loaded by the browser in a separate action (request/response cycle).
This sort of question has come up a large number of times here in the recent past so browse the last 2 weeks or so.
Bill
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Using the out object