Link to home
Start Free TrialLog in
Avatar of ashtowers
ashtowers

asked on

JCharts Problem Outputting mixed HTML / Chart page

Im using SourceForge's JChart and im trying to output a HTML with a chart integrated. I can output the chart on its own but if i add any html to the servlet (its all working via a servlet NO jsp) I get the image in text for ie random rubbish

ie

<HTML>
<TITLE>
</TITLE>
<BODY>
***runs the chart code here
</BODY>
</HTML>

What am i doing wrong? the Jcharts apparantly does the changin of the responce type itself

How do i integrate them?

ASKER CERTIFIED SOLUTION
Avatar of TimYates
TimYates
Flag of United Kingdom of Great Britain and Northern Ireland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of ashcarrot
ashcarrot

How would you deal with multiple items to chart (ie APPLE 2, BANANA 3, PINEAPPLE 3) ie you dont know how many lines to draw in your bar chart

is IMG resticted to 255(or something like that) characters after the URL like the GET method?
I'm confused...

Who's asking this question?
Yup, I agree with the question ... (is IMG resticted to 255(or something like that) characters after the URL like the GET method?)
Cause I'm having the same question in mind. But I don't think IMG had as little limit size as 255, even there is there will be more than enough ... and instead GET have a limit lenght of 255.

Regarding the suggestion of:
<HTML>
<TITLE>
</TITLE>
<BODY>
<IMG SRC="imageServlet?param1=a&param2=b&param3=c">
</BODY>
</HTML>

Actually I'm looking for the same thing, any example provided(the java src perhaps)? Then there is an additional issue worries me:"what types of image client updated to the server(jpeg,gif,png...) will be another circumstanses we need to handle in our servlet codes, right? Or it's just transparent to us(auto handle tru html's <input> tag)?"

Ya forgot to tell you all my objective, I'm doing something like capturing and storing images from client into mysql database's Blob type. Then retrieving it and displaying it back to a dynamic page(a jsp most likely)!
ashcarrot , few days b4 I had te excactly  same quetion like u ask ... 255 limit size of GET method. But I've figured it out, it wasn't.

I do not know how your code of getting the Blob type(image) from your db, as I crawl over the web ... there's plenty of solutions. PS: but none is good/ effective/ performance wise!

I use a OutputStream type to make a response to my client in a "ShowBlobImage.class", what it basically do is retrieving blob from db using byte[] and response the object. It can be query by ".../ShowBlobImage?obj_id=?"!

I strongly agree with TimYates's comment, about text/html and stream(image/*) cant be together as a response. So dun do your query in something like:

 <IMG SRC="imageServlet?param1=a&param2=b&param3=c">

, instead make it saperate like:
<IMG SRC="imageServlet?param1">
<IMG SRC="imageServlet?param2=b">
<IMG SRC="imageServlet?param3=c">

In advance you can consider using Object to encapsulate all field's value in a data object(including size, type, and filename). By doing so, is easier for a Bean construction.

Last but  not least, don't forget to set your data size and type by calling:
response.setContentType(myObj.getType());
response.setLength((int)myObj.getSize()); // since getSize() return a Long type

Regards,
Avatar Ng