[java] URL access denied

Started by
1 comment, last by CaptainJester 19 years, 6 months ago
Hi I wrote the following code (as a start):

/*
 * Applet.java
 *
 * Created on 14 October 2004, 10:36
 */

/**
 *
 * @author  Default
 */
import java.net.*;
import java.io.*;

public class Applet extends java.applet.Applet {
    
    public void init() {
        try{
            URL yahoo = new URL("http:&#47;&#<span class="java-number">47</span>;www.yahoo.com&#<span class="java-number">47</span>;"</span>);
            
            System.out.println(yahoo.getContent());
            
        }
        <span class="java-keyword">catch</span> (MalformedURLException e){}
        <span class="java-keyword">catch</span> (IOException e){}
  

     }
    
}


</pre></div><!--ENDSCRIPT-->

but I get a  access denied error. After a bit of reading I know it has something to with the Security manager not allowing me to access URL not &#111;n my localhost. Is there anyway of bypassing this?

All I need to do is be able to read the HTML code of a webpage.

Any help would be appreciated.

Talib
Try, try and fucking try again.
Advertisement
Oh and btw, I did post this on java.sun.com but nobody ever replies there.
Try, try and fucking try again.
If this applet is served from a normal web server, you could set up a gateway program that the applet could access to get to the URL you want. If not, then I think you have to digitally sign your applet and ask for permission to access other resources. I have never done it, so I don't know the specifics.
"None of us learn in a vacuum; we all stand on the shoulders of giants such as Wirth and Knuth and thousands of others. Lend your shoulders to building the future!" - Michael Abrash[JavaGaming.org][The Java Tutorial][Slick][LWJGL][LWJGL Tutorials for NeHe][LWJGL Wiki][jMonkey Engine]

This topic is closed to new replies.

Advertisement