Datatables server side processing in Java

This post explains implementing datatables server side processing in java. Check out Datatables with Spring MVC example from my previous blogs to understand in details. In this post I will be explaining server side processing on datatables, that is loading data on demand in datatable using AJAX.

The final structure of our application will be like –

datatables-server-side-processing
datatables-server-side-processing

Database Table Structure

Following data is already available in table “students“.

datatable-server-side-processing
datatable-server-side-processing

Step 1: Create a Dynamic Web Project and add dependencies and jars in the project’s lib folder present in WEB-INF folder. Here we will need two additional jars apart from Spring jars – mysql connector jar and json-object jar.

datatable-server-side-processing
datatable-server-side-processing

JSP View Pages

Step 2: Create welcome.jsp page and myDatatables.jsp page

In the above JSP, we have added an ajax callback in the data table initialization code. This means while initialization of data table an ajax call will be sent to the controller (loadServerSideData.do) to fetch the data to be loaded in Data Tables. Please make a note, only required data will be fetched and not the complete data.

XML configuration files

Step 3: Configuration files will be –

Web.xml

dispatcher-servlet.xml

Controller, Service and DAO classes

Step 4: We will now add the controller class

Step 5: Now we will create the service method and its implementation.

Step 6: Lets create the DAO layer to get the connection object.

Output

Step 7: Your application is ready to run :). The output pages will be-

datatables-server-side-processing
Output Welcome Page
datatables-server-side-processing
datatables-server-side-processing
datatables-server-side-processing
datatables-server-side-processing

Hope this will help you.

DataTableWithSpring complete application.

Regards,

Nikhil Naoghare.

10 thoughts on “Datatables server side processing in Java”

    1. Sorry but I dont have it with JSF. However it wont be that difficult to convert this in JSF application if you get the basics right for JSF.

    1. You can create the same exampled with simple JDBC as well. Instead of Spring framework you shall create the JDBC connection and get the data. Rest all functionality will be same.
      Anything else you want to know specifically?

  1. The link
    DataTableWithSpring complete application.
    Is broken can you post where the code is?

Leave a Reply

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

This site uses Akismet to reduce spam. Learn how your comment data is processed.