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 ?
-
So you would ned to make a call to the server.epascarello– epascarello2016年09月15日 20:33:18 +00:00Commented Sep 15, 2016 at 20:33
-
I think more context is needed. Is this a Java function in an Applet? Are you talking about a GWT problem?GC_– GC_2016年09月15日 20:34:09 +00:00Commented Sep 15, 2016 at 20:34
-
Like @epascarello implied an ajax call to a servlet would normally work.GC_– GC_2016年09月15日 20:35:27 +00:00Commented Sep 15, 2016 at 20:35
-
A few thoughts... You could use ajax to call what I assume could be a jsp page. Another option, use React JS or Angular JS to connect server-side.parabolah– parabolah2016年09月16日 01:49:01 +00:00Commented Sep 16, 2016 at 1:49
1 Answer 1
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:
Sign up to request clarification or add additional context in comments.
Comments
default