views:

27

answers:

2

Hello everyone,

I have a Java applet related problem and I would appreciate your help. Here's the story: I tried creating an applet, that would try to connect to digg.com and by using it's API, show the 100 most popular stories (also include some options to sort and filter the results).
Anyway, the applet opens and shows the GUI just fine in the browser, but when I press the button that loads the news, it won't load them, BUT the news are loaded, when I run the applet in Eclipse.
I thought, that maybe the problem is related to creating the runnable jar from eclipse, since I have some referenced libraries (Google GSON for handling JSON from digg.com). Here are the settings I used for creating the runnable jar (I also tried "Package required libraries into generated JAR):
http://img816.imageshack.us/img816/417/exportjar.png

Here's a picture of the applet (ran from eclipse), when the news have been loaded: http://img841.imageshack.us/img841/9121/applet.png

I would appreciate any ideas on how to get loading the news to work in the web browser.

A: 

What happens when you attempt to open the connection to digg? Is there a security exception? I wouldn't be surprised to learn that the JVM inside the browser was implementing a same origin policy. If this is the case there should be some kind of Exception (SecurityException I think) being raised when you try to connect to digg.com.

A quick search for "same origin policy java" found the following article which both seems to confirm that this could be your problem. http://www.zdnet.com/blog/security/defeating-the-same-origin-policy-part-1/946

torak
So basically, it isn't possible to make this application with an applet, because of the same origin policy :(?
ehehhh
A: 

I think torah is right. Applets should be able to connect only to their own server. You can try and trick the browser, sending request back to your server asking it to retrieve the data and to return it to applet.

spbfox