So here are the things I know. The java application is attached, there are two JPanels , one with a basic graph and one that is more detailed. These two graphs are hosted on an applet together. The applet reads a file with all the student survey data. This all hosted on an instance of Desire 2 Learn http://www.desire2learn.com/ called courselink https://courselink.uoguelph.ca/shared/login/login.html
So this all works. The aspect that doesn't is getting from courselink who is signed on so the appropriate graph can be shown. A guy that works on developing courselink gave me a php program that grabs that information and returns it in a JSON block.
The php code is hosted on a different serve then the java app (which is hosted on courselink. So here is what I have tried:
first just grabbing what the page returned from java
String name = null;
URL php = null;
try {
php = new URL ("http://coles- vs250.cs.uoguelph.ca/whoami/index.php");
} catch (MalformedURLException e) {
e.printStackTrace();
}
URLConnection yc = php.openConnection();
BufferedReader in = new BufferedReader(new InputStreamReader(yc.getInputStream()));
String inputLine;
while ((inputLine = in.readLine()) != null)
System.out.println(inputLine);
in.close();
return name;
}
Then I was going to parse out the string, parse out the users name and return it. When I run this on course link though I get a security error, and I don't really know anything about java security errors. here is the error:
Exception in thread "AWT-EventQueue-2" java.security.AccessControlException:
access denied ("java.net.SocketPermission"
"coles-vs250.cs.uoguelph.ca:80" "connect,resolve")
So next I tried to use JQuery
to call the php from the html page so then the string would be a variable on the right survey and then the java app could grab it. After some research this is what I put together. I do not know JQuery and am actually quite out of my element when it comes to this kind of programming altogether. The alerts are not showing and I don't know whats wrong.
<html>
<head>
<title>Java Example</title>
<script type='text/javascript' src='http://code.jquery.com/jquery-1.5.2.js'></script>
<script type='text/javascript'>
$(document).ready(function() {
alert("String from iframe: " + $('#whoami').contents().find('body').html());
whoami();
});
function whoami() {
$.ajax({
type: "GET",
data: {},
url: "http://coles-vs250.cs.uoguelph.ca/whoami/index.php",
success: function(data) {
alert("whoami complete: " + data);
}
});
}
</script>
</head>
<body>
<p>
<iframe style="visibility: visible;" id="whoami" src="http://coles-vs250.cs.uoguelph.ca/whoami/index.php"></iframe>--></p>
<p>
<applet width="800" height="1000" code="graphRun.class"></applet>
</p>
</body>
</html>
Any and all help or suggestions would be greatly appreciated and if there is any more info I should get or forgot I will do my best.