URLConnection and applet security
Hello,
I've got an applet that comunicates with a servlet with a urlConnection object. If I test de application without permissions of security (Applet Viewer ->Eclipse), the program runs perfectly, but when I test it in the server throws a security exception when the URLConnection connects with the servlet? How can I resolve it?
Thanks
[361 byte] By [
cacia] at [2007-10-2 13:09:20]

The first part works ok, but in the two try-catch show me the error-messages.
urlServlet = new URL(new URL("http://85.59.55.122:8080/utilidades/"),"imagen");
URLConnection con = urlServlet.openConnection();
con.setDoInput(true);
con.setDoOutput(true);
con.setUseCaches(false);
con.setRequestProperty(
"Content-Type",
"application/x-java-serialized-object");
ImagenPerso imagen=new ImagenPerso(img);
try{
OutputStream outstream = con.getOutputStream();
ObjectOutputStream oos = new ObjectOutputStream(outstream);
oos.writeObject(imagen);
oos.flush();
oos.close();
}catch(Exception er3){
JOptionPane.showMessageDialog( graph,
"Error al incrustar objetos en la peticion",
"Editor de procedimientos",
JOptionPane.ERROR_MESSAGE);
}
try{
// receive result from servlet
InputStream instr = con.getInputStream();
ObjectInputStream inputFromServlet = new ObjectInputStream(instr);
String result = (String) inputFromServlet.readObject();
inputFromServlet.close();
instr.close();
}catch(Exception i){
JOptionPane.showMessageDialog( graph,
"Error al leer objetos de la respuesta",
"Editor de procedimientos",
JOptionPane.ERROR_MESSAGE);
}
cacia at 2007-7-13 10:35:47 >

Double post:
http://forum.java.sun.com/thread.jspa?threadID=711356
Applets can only connect to the server where the applet came from (codebase).
URL u = new URL(this.getCodeBase(),"../relativePath/ToServlet");
Or you need to sign and trust the applet. And then you cannot call the method
from Javascript.
Signing applets:
http://forum.java.sun.com/thread.jsp?forum=63&thread=524815
second post and reply 18 for the java class file using doprivileged
Still problems?
A Full trace might help us out:
http://forum.java.sun.com/thread.jspa?threadID=656028