This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
The moose likes JSP and the fly likes How can I paint a chart in the jsp Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » JSP
Bookmark "How can I paint a chart in the jsp" Watch "How can I paint a chart in the jsp" New topic
Author

How can I paint a chart in the jsp

Ning Du
Greenhorn

Joined: Jul 08, 2003
Posts: 11
I want to paint a chart in the .jsp file using the data got from DataBase.
How can I do that?


SCJP1.4
Ning Du
Greenhorn

Joined: Jul 08, 2003
Posts: 11
When I make a binary file using servlet,the content of HTML cannot be displayed.What should I do? Applet?
[ August 16, 2003: Message edited by: Adu Ning ]
William Brogden
Author and all-around good cowpoke
Rancher

Joined: Mar 22, 2000
Posts: 12756
    
    5
Think about how a HTML page containing an image is built. Each chart or other image must be the result of a separate IMG tag that you write in your JSP. The SRC= attribute in the IMG tag should point to a servlet that can generate the binary image data.
You can't use a JSP to generate typical image files because a JSP is designed to output text, not binary image data. There have been a number of discussions of this here. Any book on servlets will tell you how this is done.
Bill
Ning Du
Greenhorn

Joined: Jul 08, 2003
Posts: 11
William,thank you for your reply.Someone told me img=attribute tag poits to a .dll file can also solve the question.right?
Ron Newman
Ranch Hand

Joined: Jun 06, 2002
Posts: 1056
I don't understand what you mean by that.


Ron Newman - SCJP 1.2 (100%, 7 August 2002)
Chuck Kulchar
Greenhorn

Joined: Aug 11, 2003
Posts: 4
I have my <img ...> tag point to a servlet which gets a chart using JFree chart (jfree.org), then uses a class included in the Jfree stuff that will display the image with the OutputStream. Display line is something like:
ChartUtilities.writeChartAsJPEG(out,chart,820,380);
William Brogden
Author and all-around good cowpoke
Rancher

Joined: Mar 22, 2000
Posts: 12756
    
    5
William,thank you for your reply.Someone told me img=attribute tag poits to a .dll file can also solve the question.right?

The IMG tag in HTML requires a SRC="URL" - the url is used to load the image data. That could be the URL of a servlet plus parameters that might include the name of a dll that is somehow involved. What image source do you want to use?
Bill
Ron Newman
Ranch Hand

Joined: Jun 06, 2002
Posts: 1056
What is a "dll" ?
Ning Du
Greenhorn

Joined: Jul 08, 2003
Posts: 11
Something like :<IMG height="268" border="0" width="323" SRC="http://202.108.253.131:8080/wwwhq.dll?srv=401&...">
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60741
    
  65

I believe that a DLL can be used if it implements the ISAPI interface. This of course ties one into the Microsoft platform. Not a great idea, imho.
bear


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: How can I paint a chart in the jsp
 
Similar Threads
Java Chart
JChart export to Powerpoint
Pie Chart in JSP
how to display bar chart based on the database values using jsp
Charts In JSP