• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Invoke java method from JavaScript (not applet!)

 
Ranch Hand
Posts: 50
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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?
 
Author and all-around good cowpoke
Posts: 13078
6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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 ]
 
Ranch Hand
Posts: 531
1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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 ]
 
reply
    Bookmark Topic Watch Topic
  • New Topic