Problems starting applet in browser

M

MiranL

Hello!

My code:
InputStream in = null;
URL url = new URL("http://my.url:80/myfile");
URLConnection connection = url.openConnection();
in = connection.getInputStream();

ObjectInputStream ois = new ObjectInputStream(in);
vFile = (Vector) ois.readObject(); // error



When i run this code in appletviewer i get no errors, but in browser in
get this message: access denied (Java.lang.RuntimePermission
accessClassInPackage.sun.swing)

In there any way to solve this problem without dig. signing the applet?
Or perhaps to use some alternative to ois.readObject()...
 
N

Niels Dybdahl

Hello!

My code:
InputStream in = null;
URL url = new URL("http://my.url:80/myfile");
URLConnection connection = url.openConnection();
in = connection.getInputStream();

ObjectInputStream ois = new ObjectInputStream(in);
vFile = (Vector) ois.readObject(); // error



When i run this code in appletviewer i get no errors, but in browser in
get this message: access denied (Java.lang.RuntimePermission
accessClassInPackage.sun.swing)

In there any way to solve this problem without dig. signing the applet?

It is possible without signing if your applet is started from the same
server. If the applet is started from somewhere else, it will not work.
If you use getCodeBase() instead of a hardcoded path, then you ensure that
the server is exactly the same.

Niels Dybdahl
 
M

MiranL

The problem is not in the connection between server and client but in
this line:
(Vector) ois.readObject();
 
O

Oliver Wong

The problem is not in the connection between server and client but in
this line:
(Vector) ois.readObject();

Regardless of where the exception is thrown, one of the restrictions for
unsigned applets is that you cannot connect to any server except the one
from which the applet is downloaded from. So when you're running this applet
within your browser, is the applet being downloaded from http://my.url:80/ ?

- Oliver
 
A

Andrew T.

URL url = new URL("http://my.url:80/myfile");
URLConnection connection = url.openConnection(); ....
When i run this code in appletviewer i get no errors, but in browser in
get this message: access denied (Java.lang.RuntimePermission
accessClassInPackage.sun.swing)

As you should.
In there any way to solve this problem without dig. signing the applet?

If you find one please let us know, so we can get Sun
to issue a patch for it.

Andrew T.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,995
Messages
2,570,230
Members
46,819
Latest member
masterdaster

Latest Threads

Top