Solved

JCharts Problem Outputting mixed HTML / Chart page

Posted on 2003-10-31
6
296 Views
Last Modified: 2010-08-05
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?

0
Comment
Question by:ashtowers
  • 2
  • 2
6 Comments
 
LVL 35

Accepted Solution

by:
TimYates earned 40 total points
ID: 9658128
errrr....

so you are trying to send back HTML and a jpg/gif in the same response stream?

That won't work...the response is either text/html OR image/gif ... not both in the same response...

You need to output some HTML like:

<HTML>
<TITLE>
</TITLE>
<BODY>
<IMG SRC="imageServlet?param1=a&param2=b&param3=c">
</BODY>
</HTML>

then have another servlet (imageServlet in this example) which does the image...
0
 

Expert Comment

by:ashcarrot
ID: 9658210
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?
0
 
LVL 35

Expert Comment

by:TimYates
ID: 9658222
I'm confused...

Who's asking this question?
0
 
LVL 1

Expert Comment

by:avatar21
ID: 13617966
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)!
0
 
LVL 1

Expert Comment

by:avatar21
ID: 13643667
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
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

For customizing the look of your lightweight component and making it look opaque like it was made of plastic.  This tip assumes your component to be of rectangular shape and completely opaque.   (CODE)
By the end of 1980s, object oriented programming using languages like C++, Simula69 and ObjectPascal gained momentum. It looked like programmers finally found the perfect language. C++ successfully combined the object oriented principles of Simula w…
Viewers learn how to read error messages and identify possible mistakes that could cause hours of frustration. Coding is as much about debugging your code as it is about writing it. Define Error Message: Line Numbers: Type of Error: Break Down…
This video teaches viewers about errors in exception handling.

863 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

21 Experts available now in Live!

Get 1:1 Help Now