Security permissions question about Applets

Hello all.

I'm wanting to make an address book on my server, so I need to have it write to a file. I've read a bunch about it, and still can't figure it out.

I'm not exactly sure what the java home is supposed to be. I created a java.policy file in /usr/lib/j2sdk1.5-sun (I'm on Linux), but I think it might belong in /usr/lib/j2sdk1.5-sun/jre or /usr/lib/j2sdk1.5-sun/jre/lib/security

I'm also not exactly what the java.policy file is supposed to contain. Currently, it is:

grant codeBase"file:/home/scott/public_html/address_book/old/*"{

permission java.io.FilePermission"/home/scott/public_html/address_book/old/Test.txt","write";

};

Anyone want to help?

--

Scott Howard

[871 byte] By [Scotteha] at [2007-10-2 23:24:12]
# 1

>I'm wanting to make an address book on my server, so I need to have it write to a file.

Well, applets run on the client - the browser which downloaded the class files - and therefore cannot access files on the server without some type of networking.

Caveat - the client and server are the same physical machine.

Solution - have your applet communicate back to the server it originates from. No policy twiddling is needed, as this is an automatic permission.

IanSchneidera at 2007-7-14 16:02:54 > top of Java-index,Java Essentials,Java Programming...
# 2
What do you mean? I'm wanting it to write to a file on my server. I want to be able to access it from a webpage from anywhere.
Scotteha at 2007-7-14 16:02:54 > top of Java-index,Java Essentials,Java Programming...
# 3

> What do you mean? I'm wanting it to write to a file on my server.

Applets do not run on the server, therefore they cannot directly write to files on the server.

>I want to be able to access it from a webpage from anywhere.

I understand that. I'm attempting to help you understand what you need to do.

IanSchneidera at 2007-7-14 16:02:54 > top of Java-index,Java Essentials,Java Programming...
# 4
As mentioned, if it accesses the file which resides on the same machine as the class file, you will be able to see it from anyplace the Applet can be seen from.If your Applet loads a .gif file, for example, that .gif file is in a folder near the Applet class file. Same idea here
abillconsla at 2007-7-14 16:02:54 > top of Java-index,Java Essentials,Java Programming...
# 5
So if I access the Applet from someIP, then it will try to find file:/home/scott/public_html/address_book/Test.txt at someIP but not at myIP?
Scotteha at 2007-7-14 16:02:54 > top of Java-index,Java Essentials,Java Programming...
# 6
correct
IanSchneidera at 2007-7-14 16:02:54 > top of Java-index,Java Essentials,Java Programming...
# 7
Ok then, how can I have an applet communicate with my server like you suggested? I've never done this before and have no idea how to do it.
Scotteha at 2007-7-14 16:02:54 > top of Java-index,Java Essentials,Java Programming...
# 8
http://java.sun.com/docs/books/tutorial/deployment/applet/server.html
IanSchneidera at 2007-7-14 16:02:54 > top of Java-index,Java Essentials,Java Programming...
# 9
Thanks man. Duke dollars awarded to you.
Scotteha at 2007-7-14 16:02:54 > top of Java-index,Java Essentials,Java Programming...
# 10
Your welcome.yeeee haw.
IanSchneidera at 2007-7-14 16:02:54 > top of Java-index,Java Essentials,Java Programming...