Alvin, I've used JFreeChart (which cewolf) is based on. Both are frameworks for creating charts in Java. You get the data from the database through JDBC, just like you would for any web application. After storing that data somewhere appropriate (like in the HttpRequest), you call the framework to draw the chart.
If you have more questions about JDBC, post them here. If this question is more about cewolf, let me know and we can move this to the JSP forum.