1

I am looking for how to implement jQuery DataTables with server-side processing in Java. I have tried the following way by using the below parameters. Below is my jQuery ready function code.

$(document).ready(function() {
    //url = http://localhost:8080/jQuery-DataTable-Java-Integration/serverExample
    $('#myTableId').DataTable({
        "serverSide" : true,
        "processing" : true,
        /*"bProcessing" : true,
        "bServerSide" : true,*/
        "ajax" : {
            "url" : "serverExample",
            "type" : "POST"
        },
        "columns" : [ {
            "data" : "Phone Number"
        }, {
            "data" : "name"
        }, {
            "data" : "Email"
        } ]
    });
});

In my servlet doPost() method I the request parameter sEcho is null.

protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        logger.info("In do post method of server servlet..");
        logger.info("sEcho request parameter = " + request.getParameter("sEcho"));//returning null
//other code here
}

My jQuery DataTables version is 1.10.7. Which parameters should be used, serverSide or bServerside, I tried both ways, but still the same. Any latest updated working example references would be helpful.

1 Answer 1

4

When using DataTables 1.10 version in server-side processing mode, client side sends draw parameter along with other parameters. Full list is shown on DataTables website.

Previous version of DataTables 1.9 used sEcho parameter in server-side processing mode, see documentation for more information.

If you have server-side script written for DataTables 1.9, it is possible to force DataTables 1.10 to send parameters compatible with previous version. Below is an excerpt from the manual:

Older versions of DataTables (1.9-) used a different set of parameters to send and receive from the server. As such scripts which are written for DataTables 1.10+ will not be able to function with DataTables 1.9-. However, DataTables 1.10 does have a compatibility mode for scripts written for 1.9-. This compatibility mode is triggered by use of the old sAjaxSource parameter (rather than the new ajax parameter) or by setting$.fn.dataTable.ext.legacy.ajax = true; .

You should be using serverSide and processing which are preferred option names for version 1.10 although it accepts option names (bServerSide and bProcessing) for previous version as well.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.