AccessControlException in an applet

This applet runs fine when I run it from eclipse, but as soon as I stick it into a web page I get this error in the java console:

Exception in thread"AWT-EventQueue-2" java.security.AccessControlException: access denied (java.net.SocketPermission wow.allakhazam.com:80 connect,resolve)

at java.security.AccessControlContext.checkPermission(Unknown Source)

at java.security.AccessController.checkPermission(Unknown Source)

at java.lang.SecurityManager.checkPermission(Unknown Source)

at java.lang.SecurityManager.checkConnect(Unknown Source)

at sun.net.www.http.HttpClient.openServer(Unknown Source)

at sun.net.www.http.HttpClient.<init>(Unknown Source)

at sun.net.www.http.HttpClient.New(Unknown Source)

at sun.net.www.http.HttpClient.New(Unknown Source)

at sun.net.www.protocol.http.HttpURLConnection.getNewHttpClient(Unknown Source)

at sun.net.www.protocol.http.HttpURLConnection.plainConnect(Unknown Source)

at sun.net.www.protocol.http.HttpURLConnection.connect(Unknown Source)

at sun.net.www.protocol.http.HttpURLConnection.getInputStream(Unknown Source)

at java.net.URL.openStream(Unknown Source)

at ItemLister.getItemNumber(ItemLister.java:75)

at ItemLister.actionPerformed(ItemLister.java:65)

at java.awt.Button.processActionEvent(Unknown Source)

at java.awt.Button.processEvent(Unknown Source)

at java.awt.Component.dispatchEventImpl(Unknown Source)

at java.awt.Component.dispatchEvent(Unknown Source)

at java.awt.EventQueue.dispatchEvent(Unknown Source)

at java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source)

at java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source)

at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)

at java.awt.EventDispatchThread.pumpEvents(Unknown Source)

at java.awt.EventDispatchThread.pumpEvents(Unknown Source)

at java.awt.EventDispatchThread.run(Unknown Source)

The code that is causing this exception is:

private String getItemNumber(URL curURL, String name){

try{

BufferedReader br =new BufferedReader(new InputStreamReader(curURL.openStream()));

String curLine = br.readLine();

while(!curLine.contains("db/item.html?witem=")){

curLine = br.readLine();

}

String[] split = curLine.split("witem=");

String[] numberSplit = split[1].split("&");

return numberSplit[0];

}catch (IOException e){

result.setText("Invalid item name for" + name);

thrownew RuntimeException();

}

}

All this is doing is searching the webpage for the right code, then it will take the number that follows this correct code. Any idea why I don't have permission to access that website?

[3456 byte] By [oliverj4455a] at [2007-11-27 5:31:30]
# 1
For security reasons applets can only connect back to the server from whence they came.
cotton.ma at 2007-7-12 14:56:46 > top of Java-index,Java Essentials,Java Programming...
# 2
anything i can do about this? :D
oliverj4455a at 2007-7-12 14:56:46 > top of Java-index,Java Essentials,Java Programming...
# 3
> anything i can do about this? :DI am fairly certain the answer is no.
cotton.ma at 2007-7-12 14:56:46 > top of Java-index,Java Essentials,Java Programming...
# 4
Seems a little odd that a WEB applet can't interact with other WEBsites, oh well, thanks for your quick response :D
oliverj4455a at 2007-7-12 14:56:46 > top of Java-index,Java Essentials,Java Programming...
# 5

> Seems a little odd that a WEB applet can't interact

> with other WEBsites, oh well, thanks for your quick

> response :D

Not really. It is a good security restriction.

You can connect to any website you want from an application. But better to restrict an applet I think.

cotton.ma at 2007-7-12 14:56:46 > top of Java-index,Java Essentials,Java Programming...
# 6
Anyway see http://java.sun.com/sfaq/#socket
cotton.ma at 2007-7-12 14:56:46 > top of Java-index,Java Essentials,Java Programming...