| 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>
|
 |
William Brogden
Author and all-around good cowpoke
Rancher
Joined: Mar 22, 2000
Posts: 12268
|
|
I think you are going to have a JavaScript security problem on the browser side. Using JS to load stuff from different IP addresses was determined to be a gaping security hole many years ago. The same restrictions apply to applets trying to open connections to different addresses. You can have a server-side function effectively relay the query and send the results back to JS. Bill
|
Java Resources at www.wbrogden.com
|
 |
Vlad Golodov
Ranch Hand
Joined: Jul 05, 2004
Posts: 50
|
|
Thanks for the answer It's not possible to execute something on user's site. I can put only small JS code into his page. Problem is that i need to show two types of buttons on site. One type will be shown if statement from my server returns true, another if false. It's possible to write a jsp or servlet that will return the result on my site. Then from JS i can execute URL and get the text of document like variable. But i don't know how to execute url and get this text in JS. Maybe it's not possible too. I have searched about it, but found nothing helpfull. [ July 06, 2004: Message edited by: Vlad Golodov ]
|
 |
Anton Golovin
Ranch Hand
Joined: Jul 02, 2004
Posts: 473
|
|
just put an iframe with a fixed source to your JSP that will display the correct buttons. I see no other way. [ July 09, 2004: Message edited by: Anton Golovin ]
|
Anton Golovin<br /><i>anton.golovin@gmail.com</i><br />SCJP, SCJD, SCBCD, SCWCD
|
 |
 |
|
|
subject: Invoke java method from JavaScript (not applet!)
|
|
|