$("#btnDel").on("click",function(){
var idsarray = [];
$("input:checkbox[name=delbox]:checked").each(function() {
                idsarray.push($(this).val());
            });
        console.log(idsarray);  
var idsString = idsarray.join();
console.log(idsString);
   $.ajax({
    url: 'StudentController',
    dataType: 'json',
    data: {
        "idsToBeDeleted" : idsString
    },
    type: 'DELETE'
    });
});
this is the JS code , im catching the ids of the checkboxes and sending them as a comma separated string to the servlet . thing is when i try to catch the variable on the servlet , and print it out , all i get is null .
protected void doDelete(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        //catching values from recieved ajax request
                String idlistString = (String) request.getParameter("idsToBeDeleted");
                System.out.println(idlistString);
                
                response.sendRedirect(request.getContextPath());
    }
servlet code over here , some explanation on how to usually catch the sent data through an ajax request would be appreciated .
 
    