• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Calling a Java method from a JavaScript function

 
Somnath Mallick
Ranch Hand
Posts: 482
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi All,

Could you tell me how to do this? I Google'ed a lot but found many ways to call a JS file from Java, but not much for this one.
 
Jeanne Boyarsky
author & internet detective
Marshal
Posts: 34071
331
Eclipse IDE Java VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
That's because you can't. JavaScript is run in the browser. Java is run on the server or in an applet.

You can have your JavaScript function submit a form to the server or make an AJAX call to the server.
 
Somnath Mallick
Ranch Hand
Posts: 482
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Oh man! Don't know Ajax.

Could you show me some examples to do this. Some links would be helpful!
 
Jeanne Boyarsky
author & internet detective
Marshal
Posts: 34071
331
Eclipse IDE Java VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ajax is a giant topic. It might not even be what you need. What are you trying to accomplish?
 
Somnath Mallick
Ranch Hand
Posts: 482
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am trying to call a method of a Java class from JS function which returns Boolean value.
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64618
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Somnath Mallick wrote:I am trying to call a method of a Java class from JS function which returns Boolean value.

That is not what you are trying to accomplish -- that's how you are trying to accomplish it.

What are you trying to accomplish?
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic