Hi
I'm writing an applet that sends an SQL statement to a servlet accross a network and then receives the results as a vector. Here is the code I use:
try{
URL sqlServlet = new URL("http://193.61.149.35/smarthome/SmartHomeSQLServer");
URLConnection servletConnection = sqlServlet.openConnection();
servletConnection.setDoOutput(true);
servletConnection.setUseCaches(false);
servletConnection.setRequestProperty("Accept", "text/html");
servletConnection.setRequestProperty("Content-Type","application/x-www-form-urlencoded");
// Send POST output.
OutputStreamWriter printout = new OutputStreamWriter(servletConnection.getOutputStream());
String sql = "SELECT * FROM test WHERE number='1';";
String content = "SQL=" + URLEncoder.encode(sql);
printout.write(content);
printout.flush();
// Get the response
ObjectInputStream ois = new ObjectInputStream(servletConnection.getInputStream());
Vector v = (Vector) ois.readObject();
printout.close();
ois.close();
}catch( Exception E){
JOptionPane.showMessageDialog(null, E.getMessage());}
The problem is that when the line: OutputStreamWriter printout = new OutputStreamWriter(servletConnection.getOutputStream()); is executed an exception is thrown. The exception is: access denied(java.net SocketPermission)
Can anyone tell me why this is happening and how I can fix it.