| Author |
Invoke java method from JavaScript (not applet!)
|
Vlad Golodov
Ranch Hand
Joined: Jul 05, 2004
Posts: 50
|
|
I need to invoke a simple method from users site. For example, it could be public class Test{ public Test(){ } public String getString(String parameter){ return "String"; } } From JS i need to getString from Test. My class will work with Oracle and will be located on a different ip-address. Is it possible without Applet?
|
SCJP, SCJWSD prepairing<br /><a href="http://www.vladgolodov.com" target="_blank" rel="nofollow">http://www.vladgolodov.com</a>
|
 |
Rachel Swailes
Ranch Hand
Joined: May 18, 2004
Posts: 434
|
|
To invoke a java method from javascript - have a look at http://www.rgagnon.com/howto.html Then click on java and go to Javascript interaction. Cheers, Rachel
|
 |
Vlad Golodov
Ranch Hand
Joined: Jul 05, 2004
Posts: 50
|
|
Thanks for the good resourse, but i can't use applets in my task. Even if i would use applets, they wouldn't permit to make a call from other domain Maybe there are more possibilities how to get variable from java to JS? I have to check if(variable == true) 1 else 2 And i have to take this variable from java located on different site. On client site can use only small JS code.
|
 |
M. Gagnon
Ranch Hand
Joined: Feb 18, 2004
Posts: 68
|
|
If you are using JSP, you might be able to do it with an expression. I did this once with ASP. For example, if your javascript code needs to use a JSP variable: function myJsFunction () { var jsVar = <%= jspVar %>; } The jspVar could be a value returned from a Java method. I haven't tried this in JSP, but it did work in ASP.
|
 |
 |
|
|
subject: Invoke java method from JavaScript (not applet!)
|
|
|