Search code examples
javascriptjavaajaxservletsatg

Is there any way to fine which js file ajax function send a request to java servlet


I have two js files one.js and two.js in both js i make the ajax request to same java servlet class(AppController.java //servlet class name).

one.js

function addOne(){
    var formData = $('#form1').serialize();
    $.ajax({
        type: "POST",
        data: formData,
        dataType: "json",
        success: function (response) {
            ...
        }
    });
}

two.js

function removeMulti(){
    var formData = $('#form').serialize();
    $.ajax({
        type: "POST",
        data: formData,
        dataType: "json",
        success: function (response) {
            ...
        }
    });
}

is there any way to fine or identify which js file ajax send the request to AppController.java servlet class. Because i need to block some jsp file access via url enter and ajax call. That jsp file access only in jsp include in another jsp file and particular js file ajax call.

Note : Already I block the url and ajax request to access the specific jsp page using filter class. but I need to access that jsp file specific js file ajax request only.


Solution

  • Just add a header to your ajax call to identify which file is calling.