Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

JCharts Problem Outputting mixed HTML / Chart page

Posted on 2003-10-31
6
Medium Priority
?
326 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
6 Comments
 
LVL 35

Accepted Solution

by:
TimYates earned 160 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

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

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

INTRODUCTION Working with files is a moderately common task in Java.  For most projects hard coding the file names, using parameters in configuration files, or using command-line arguments is sufficient.   However, when your application has vi…
For beginner Java programmers or at least those new to the Eclipse IDE, the following tutorial will show some (four) ways in which you can import your Java projects to your Eclipse workbench. Introduction While learning Java can be done with…
Viewers will learn about the different types of variables in Java and how to declare them. Decide the type of variable desired: Put the keyword corresponding to the type of variable in front of the variable name: Use the equal sign to assign a v…
Viewers will learn about if statements in Java and their use The if statement: The condition required to create an if statement: Variations of if statements: An example using if statements:
Suggested Courses

636 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