I am trying to call a method in a Java applet from JS. I am a little bit confused about how to arrange my workflow. I have a jsp (pending.jsp) class which includes a javascript (pending.js). pending.jsp is just a container to hold pending.js. pending.js’ purpose is to enable users to cancel report creation.
pending.jsp:
<div id="pending-reports-container" class="pending-reports-container">
<div id="pending-reports">
</div>
</div>
pending.js:
function update_pending_reports(response_data)
{ bla }
function delete_report(report_id)
{ bla }
function request_pending_reports()
{ bla }
function start_pending_reports() {
request_pending_reports();
setInterval("request_pending_reports()", 5000);
}
Because cancelling reports sometimes is not that efficient I want to use Java to cancel requests that goes to the postgres (pending.js does not kill the process that works at postgres). I created my Java class but I don’t know where to add it. I know I can make use of tag, but when I tried to add this tag to my jsp file like this:
<div id="pending-reports-container" class="pending-reports-container">
<div id="pending-reports">
<applet id="LS" width=1 height=1 code ="module/LicenseCheckService.class" codebase="."/>
</div>
</div>
I can not reach it from my pending.js with this code:
getJS = document.getElementById("LS");
Is there something wrong with my code or am I wrong at this structure in the first place?
See the Invoking Applet Methods From JavaScript Code Oracle docs.
Nutshell version is that the JavaScript refers to the applet object by the applet ID, and can call methods on it.