Execute JSP containing JavaScript in background

I have a logic to generate pdf written in js in my JSP.

AutoDownloadPDF.jsp:

setInterval(function() {
        $.ajax({
        type: "POST",
        url: "GetInvoicesNo.jsp?EntityID=40&MappingID=<%=getMappingID%>",
        async: false,
        success: function(data){    
        var splitData =data.trim().split(',');
                $.each(splitData, function(index, value){
                if(value.trim()!=''){
                var url="GeneratePDF.jsp?EntityCode=<%=getEntityCode%>&InvoiceNo="+value;
        var printWindow = window.open(url,"_blank");
                 }
                        
            });     
                    
    }
    }); 
}, 90000);          

Current Setup:

I’m triggering AutoDownloadPDF.jsp through a Windows batch script like this:

msedge --app=http://localhost:8088/APP/AutoDownloadPDF.jsp 

The process works as intended; however, this method is unsuitable for my server environment because the server may log off, which causes Microsoft Edge to close and interrupts the process.

I tried tools like HTMLUnit and Playwright but didn’t work for me. It seems the problem is that the JSP depends heavily on browser-based JavaScript. Are there any tools or approaches that can handle this effectively?