Fadwa Estuka
Fadwa Estuka

Reputation: 31

How to call external java functions from javascript code?

I have two separate java and javascript file. I want to call a method which is in my java class from my javascript function. Can anyone help me please ?

Upvotes: 1

Views: 642

Answers (1)

cstopher
cstopher

Reputation: 261

I'm not sure what the structure of your code looks like but you cannot call a java method directly from javascript. You would need to use something that can map your URL to the method you are calling. You would need to make a servlet or JSP and use an ajax call to communicate to the server and call your desired method.

The following tutorial should help you get started writing something like this:

https://netbeans.org/kb/docs/web/ajax-quickstart.html

Upvotes: 1

Related Questions