HighChart using AJAX, JSP and Servlet

We know that HighChart basically displays different statistical data on different chart types such as column chart, bar chart, line chart, pie chart etc. You can have a look at the URL http://www.highcharts.com/ for more information.

You can integrate HighChart with any server side technology but here I will show you how to integrate HighChart using AJAX, JSP and Servlet. This tutorial shows step by step so that we can understand how it happens. It displays the data for site visitors log in line chart. I have also put a calendar for date-picker so that you can pick a custom range of dates and get the visitor statistics in HighChart. The calendar has more features like you can select Today, Yesterday, Last One week, Last One month etc. On mouse hover on the line chart you can see the visitors count on a particular date.

If you have any query please feel free to leave a comment.


JDK 1.7
Eclipse 3.6
Maven 2.x
Tomcat Server 7.x
HighChart API

Final Output

HighChart using AJAX, JSP and Servlet

Now we will see steps how to implement it

Step 1. Create a maven based web project in Eclipse

Step 2. Modify pom.xml file as shown below

Step 3. Modify web.xml file as shown below

Step 4. Create a POJO class for HighChart data model

Step 5. Create sample static data for HighChart. You will usually fetch dynamic data from your database and show your data onto HighChart.

Step 6. Create a servlet that will handle request and response from a user

Step 7. Create a JSP file for viewing the graph

Step 8. AJAX call through jQuery and HighChart API

Step 9. Download below assets directory and put it under webapp directory


Step 10. Run the application on Tomcat server. You will get the desired output in the browser.

That’s all. Thanks for reading.


Software Professional, I am passionate to work on web/enterprise application. For more information please go to about me. You can follow on Twitter. You can be a friend on Facebook or Google Plus or Linkedin

2 thoughts on “HighChart using AJAX, JSP and Servlet

  1. Hi, My name is Ashish Sarkar. I have tried this Highchart using my own logic. So I have taken the servlets and jsp and I am converting the data into Json data. The problem I am facing is the Null Pointer Exception. I read some oracle docs for the cause of Null Pointer Exception. I realized there is some misconception implementation in “contextpath”. I tried to change the context path. But I still get the same error.
    SEVERE: Servlet.service() for servlet [jsp] in context with path [/MavenPractice] threw exception [java.lang.NullPointerException] with root cause java.lang.NullPointerException

    I dont have the option to show you my code. If you can provide me your mail address, I can mail you my project. please help me out.

    Ashish Sarkar

Leave a Reply

Your email address will not be published. Required fields are marked *

Time limit is exhausted. Please reload CAPTCHA.