• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Invoke java method from JavaScript (not applet!)

 
Vlad Golodov
Ranch Hand
Posts: 50
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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?
 
William Brogden
Author and all-around good cowpoke
Rancher
Posts: 13073
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
Vlad Golodov
Ranch Hand
Posts: 50
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 476
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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 ]
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic