File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes HTML, CSS and JavaScript and the fly likes Calling a Java method from a JavaScript function Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of OCM Java EE 6 Enterprise Architect Exam Guide this week in the OCMJEA forum!
JavaRanch » Java Forums » Engineering » HTML, CSS and JavaScript
Bookmark "Calling a Java method from a JavaScript function" Watch "Calling a Java method from a JavaScript function" New topic
Author

Calling a Java method from a JavaScript function

Somnath Mallick
Ranch Hand

Joined: Mar 04, 2009
Posts: 477
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
internet detective
Marshal

Joined: May 26, 2003
Posts: 30405
    
150

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.


[Blog] [JavaRanch FAQ] [How To Ask Questions The Smart Way] [Book Promos]
Blogging on Certs: SCEA Part 1, Part 2 & 3, Core Spring 3, OCAJP, OCPJP beta, TOGAF part 1 and part 2
Somnath Mallick
Ranch Hand

Joined: Mar 04, 2009
Posts: 477
Oh man! Don't know Ajax.

Could you show me some examples to do this. Some links would be helpful!
Jeanne Boyarsky
internet detective
Marshal

Joined: May 26, 2003
Posts: 30405
    
150

Ajax is a giant topic. It might not even be what you need. What are you trying to accomplish?
Somnath Mallick
Ranch Hand

Joined: Mar 04, 2009
Posts: 477
I am trying to call a method of a Java class from JS function which returns Boolean value.
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61106
    
  66

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?


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
 
 
subject: Calling a Java method from a JavaScript function