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?

