Introduction
In this article, we will see how to develop Highcharts in JSP and Servlets. You can develop Highcharts in .Net, also. Suppose a project, that is developed in JSP and Servlet, is running. Now, we need a particular entry to calculate the total cost of the project in a number of days. While showing the graph, it is displaying a percentage and percentage ratio of how much it is pending with a pie chart drill down. Let's start.
Prerequisites
- You need Netbeans setup. Kindly Download Netbeans setup from official website.
https://netbeans.org/downloads/ - You need to install Java and map the path in the environment variables section.
- Oracle. I developed these Highcharts in Oracle. You can download Oracle setup from this link.
http://www.oracle.com/technetwork/database/enterprise-edition/downloads/index-092322.html - If any error comes while installing the Oracle, you can refer to this blog.
http://www.c-sharpcorner.com/blogs/oracle-11g-r2-installation-error-in-windows - You can also develop the same thing in SQL. You just need sufficient data to show in the graph.
- Download Highchart JS from this link.
http://www.highcharts.com/download.Now, we are ready to start.
NOTE: When you install NetBeans, it will ask the platform on which you want to run the project. There are mostly two platforms: Apache Tomcat Server and Glassfish. If you select Apache Tomcat server, the project will run on that platform. I had selected a Glassfish server.
The difference between Apache Tomcat Server and Glassfish servers is - In apache Tomcat server, it only has the implementation of JSP and Servlets, whereas Glassfish or JBoss, has the full implementation of all servers, like Junit, Java EE and so on.
Open Netbeans Setup. On the left side of the pane, you will see these options:

You can also add servers from here if you missed that while installing. Now, let's start with the code.
Go To File->New Project.
Now, you will get a prompt.
Create Web Application ->Next. Give suitable name and destination.

Click Next. Now, see carefully. It will ask, " On which server do you want to run your project?" You can select the Servers from here. I selected GlassFish server.

Click Next. It will ask for Framework on which you want to develop these, like Struts, Hibernate and so on. I haven’t selected any. Click Next and create a sample application .


Now, we will add a JSP page here and will name it as report.jsp.
Right-click on Web Pages and add new JSP.

Name it as Report.

It will ask for the location where you want to create it. See the details carefully and click Finish. You will see that Report.jsp is successfully created.
Now, just open that JSP page. JSP is nothing but an HTML Page.
Here, you will see the title of the page and it's displaying Hello. Now, we will run the project and see what output are we getting. Just run the project.

When you run the project, you see that the Glassfish Server has started.

You will see Hello World! displayed. That means we have successfully created a JSP file and run our project and got output.
Now, we will add Highcharts JS which we had downloaded. Kindly Include a folder called JS.

Just copy all the Highchart JS files in the JS folder.
Now, let's include those JS in our JSP file.
Now, we will be exploring more on Highchart, such as - what kind of chart we want - say Pie, and in which color we want it. Just add these lines in the code to draw the chart. Now, as you have seen, there are three charts. So, we need three results sets, three divs, and three variables to store those outputs and display in chart.
For now, just add these lines:
- <script type="text/javascript">
- $(function() {
- Highcharts.theme = {
- colors: ['#058DC7', '#50B432', '#ED561B', '#DDDF00', '#24CBE5', '#64E572', '#FF9655', '#FFF263', '#6AF9C4'],
- chart: {
- backgroundColor: {
- linearGradient: { x1: 0, y1: 0, x2: 1, y2: 1 },
- stops: [
- [0, 'rgb(255, 255, 255)'],
- [1, 'rgb(240, 240, 255)']
- ]
- },
- borderWidth: 2,
- plotBackgroundColor: 'rgba(255, 255, 255, .9)',
- plotShadow: true,
- plotBorderWidth: 1
- },
- title: {
- style: {
- color: '#000',
- font: 'bold 16px "Trebuchet MS", Verdana, sans-serif'
- }
- },
- subtitle: {
- style: {
- color: '#666666',
- font: 'bold 12px "Trebuchet MS", Verdana, sans-serif'
- }
- },
- xAxis: {
- gridLineWidth: 1,
- lineColor: '#000',
- tickColor: '#000',
- labels: {
- style: {
- color: '#000',
- font: '11px Trebuchet MS, Verdana, sans-serif'
- }
- },
- title: {
- style: {
- color: '#333',
- fontWeight: 'bold',
- fontSize: '12px',
- fontFamily: 'Trebuchet MS, Verdana, sans-serif'
- }
- }
- },
- yAxis: {
- minorTickInterval: 'auto',
- lineColor: '#000',
- lineWidth: 1,
- tickWidth: 1,
- tickColor: '#000',
- labels: {
- style: {
- color: '#000',
- font: '11px Trebuchet MS, Verdana, sans-serif'
- }
- },
- title: {
- style: {
- color: '#333',
- fontWeight: 'bold',
- fontSize: '12px',
- fontFamily: 'Trebuchet MS, Verdana, sans-serif'
- }
- }
- },
- legend: {
- itemStyle: {
- font: '9pt Trebuchet MS, Verdana, sans-serif',
- color: 'black'
- },
- itemHoverStyle: {
- color: '#039'
- },
- itemHiddenStyle: {
- color: 'gray'
- }
- },
- labels: {
- style: {
- color: '#99b'
- }
- },
- navigation: {
- buttonOptions: {
- theme: {
- stroke: '#CCCCCC'
- }
- }
- }
- };
- // Apply the theme
- var highchartsOptions = Highcharts.setOptions(Highcharts.theme);





Vignesh ManiPosted Jul 27, 2016, 12:11 PM
Good Work
kalu singh raoPosted Jul 25, 2016, 1:44 AM
Good one