Accessing Client Disk with 1.1

I read(somewhere) that the Java spec. allows for applet access to the local diskin a restricted way. That is, the client should be able to specify adirectory on the disk that Java can access. Is this true? Netscape’simplementation does not support this. Is this a Java language issue orNetscape implementation issue? How else could I implement some sort of fileupload in Java?

What an applet can or cannot do at runtime is determined by the particularimplementation of the Java Security Manager that comes with the browserrather than the version of the Java language itself. In general, theSecurity Manager in a browser prevents applets from reading, writing,renaming or removing any files, but the details of how the policy isenforced is up to the browser. For example, the security manager in Netscape prevents applets from reading,writing or accessing any files whatsoever.

However, the security managers in Sun’s Hotjava and Appletviewer are moreconfigurable. They allow applets to read files when they are explicitlynamed on user-defined access control lists. The access control list is nullby default but can be defined in the ~/.hotjava/properties file by the user.

(The “~” symbol refers to the user’s home directory on UNIX systems. On aPC, if the web browser is installed in the C: drive, then the propertiesfile resides in C:.hotjavaproperties)

The property specifies which files or directories are readable byapplets and the acl.write property specifies which files or directories canbe written by applets. When is not defined, no applet can read anyfile and likewise, so long as acl.write hasn’t been defined, applets cannotwrite to any files.

You can define individual files or directories to be readable or writeableby simply adding a line to the properties file as follows:

                      acl.write=/htdocs/visitorcounter                        -or-                      acl.write=/home/incoming/images
To define multiple items on the access control list, separate the entries,with a “:”
Allowing an applet to read/write a directory means that it can read/writeall the files in that directory, including any files in any subdirectoriesthat might be hanging off that directory.

Also note that allowing write access to files or directories opens up yoursystem to potential mischief by applets that might rename files, consumelarge amounts of disk space, remove your files, etc. Be cautious in usingthis scheme and avoid it if at all possible. Instead have your applets keepany state they need back on the server where they reside.

Share the Post:
Share on facebook
Share on twitter
Share on linkedin


The Latest

microsoft careers

Top Careers at Microsoft

Microsoft has gained its position as one of the top companies in the world, and Microsoft careers are flourishing. This multinational company is efficiently developing popular software and computers with other consumer electronics. It is a dream come true for so many people to acquire a high paid, high-prestige job

your company's audio

4 Areas of Your Company Where Your Audio Really Matters

Your company probably relies on audio more than you realize. Whether you’re creating a spoken text message to a colleague or giving a speech, you want your audio to shine. Otherwise, you could cause avoidable friction points and potentially hurt your brand reputation. For example, let’s say you create a

chrome os developer mode

How to Turn on Chrome OS Developer Mode

Google’s Chrome OS is a popular operating system that is widely used on Chromebooks and other devices. While it is designed to be simple and user-friendly, there are times when users may want to access additional features and functionality. One way to do this is by turning on Chrome OS