Link to home
Start Free TrialLog in
Avatar of cmreichl
cmreichl

asked on

Java Applet - File Output possibilities?

I have a Java Applet program I wrote to run a psychology experiement. It displays a series of words and records response time from the user.  I'd like to have it output results to a textfile(continuosly adding to end of file).  Is there anyway possible to have a java applet running locally output to a file?  I've tried modifying the security permissions in the browser, but still can't get it to work!  If this isn't possible... any suggestions?

Thanks,
Chris
ASKER CERTIFIED SOLUTION
Avatar of CEHJ
CEHJ
Flag of United Kingdom of Great Britain and Northern Ireland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of bjornsone
bjornsone

Yes it's possible, but it's not worth the hassle.

The applet does not by default have sufficient security privileges, so you
need to assert the proper authority.  The method of doing this is not consistent
between all browser (netscape, Microsft Internet Explorer, and Sun's java plugin).
I can give you code snippets I found and have used for the first
two browsers, but I haven't yet worked with Sun's plugin.

Furthermore, I know that netscape and Internet Explorer require
you to sign your code with a digital certificate before it will allow
your code to get outside of the java sandbox.  I got a code signing
certificate from the security company Thawte (cost and lots of hassle)
in order to get our java code to work with the file system.

The java applet does have permission to make http requests
to the server from which it was downloaded.  You could have
the applet give the information to the server using the HTTP
request, and the server could keep track of the data using the
local file system or a database.  The user could then have an
option to view or download the file from the server using a link
from within their web browser.
The server could use a servlet to generate the content to be
downloaded by using either the file or a database query.

The server would need to identify different users in order to
let each person download his/her own data.  Cookies could
be used for this purpose.

This system would work, but it would not be trivial to implement
if you are not experienced.  

I hope somebody else can find an easier work-around for the
java security restrictions on the applet.
:-)