Solved

JCharts Problem Outputting mixed HTML / Chart page

Posted on 2003-10-31
6
300 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

DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
java.io.BufferedReader   readLine()  //returns the entire file ? 4 73
session migration servlets 2 36
fibonacci ten numbers 4 38
hibernate example for saving data 19 40
Introduction This article is the first of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article explains our test automation goals. Then rationale is given for the tools we use to a…
In this post we will learn how to connect and configure Android Device (Smartphone etc.) with Android Studio. After that we will run a simple Hello World Program.
Video by: Michael
Viewers learn about how to reduce the potential repetitiveness of coding in main by developing methods to perform specific tasks for their program. Additionally, objects are introduced for the purpose of learning how to call methods in Java. Define …
This tutorial covers a practical example of lazy loading technique and early loading technique in a Singleton Design Pattern.

777 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