Create Charts using FusionCharts and Jetty Server

Jetty is an HTTP based web server, which can be used to communicate between machines in large software frameworks. Jetty is an open source server under Apache/Eclipse license. An easy to use server which can be easily embedded in devices, tools, frameworks and application servers.

This tutorial showcases how you can render charts using FusionCharts and Jetty Server.

System requirements

To start rendering charts using Jetty server, you need to make sure that you have the following components downloaded on your local machine:

Install Jetty Server

To start your jetty server, install it from the terminal using the following command:

Note:

  • If using Netbeans, download the plugins to work with jetty server
  • If using Eclipse IDE, download the plugins to work with jetty server

Configure the Application

Follow the steps given below to create and configure the jetty server:

  • Open IDE and select New Project
  • Create a Java Web application and click next
  • Select your server and click next

Creating Chart Object

To create charts using Fusioncharts in jetty server, include JSP wrapper into the source package. Once done add the following line of codes in your index.jsp page:

Note: Don’t forget to include the fusioncharts library files to your working folder.

Rendering the Chart

Now, you are ready to render FusionCharts using jetty server. Press CTRL + f5 to run and check the output of the chart as shown in image below:

If you find any difficulty in rendering the chart or you see any error in your code, click here to download the complete source code of the sample project we have created for this tutorial.

Was There a Problem Rendering Charts?

In case something went wrong and you are unable to see the chart, check for the following:

  • The chart ID should be unique for all charts rendered on the same page. Otherwise, it will result in a JavaScript error.
  • If the chart does not show up at all, check if the fusioncharts.js and fusioncharts wrapper FusionCharts.java was loaded. Also, check if the path to fusioncharts.js and FusionCharts.java file is correct, and whether the file exists in that location.

Leave a Comment