How to call a Java function inside JavaScript Function?


JavaScript cannot call java method directly since it is on the server. You need a Java framework like JSP to call when a request is received from JavaScript. Let’s see how to use JSP to call a Java function inside JavaScript function.

Here’s the JavaScript code:

//javascript code
function initiateFunc() {
   $.get('localhost/project/myexecution.jsp);
}
$( initiateFunc);

 Here’s the JSP code for “myexecution.jsp”:

<%@ page import="deleteconfig"%>
<%
   deleteconfig.initiate();
%>

Updated on: 03-Oct-2019

5K+ Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements