Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

FileOutputStream in applets?

Status
Not open for further replies.

RedLion

Programmer
Sep 13, 2000
342
NL
Hello,

I would like to use FileOutputStream in an applet, but it doesn't work? In an application it works well. Can it be that it is a security question?

And if so, how to work around this?

Thanks,

Charl
 
Hi,

Yes, this is a security question. What you would have to do is to get your applet signed. If you just want to do testing, you can edit your policy file - java.policy(but please remember to change it back after testing). This file is found in the folder c:\Program Files\JavaSoft\JRE\1.3\lib\security\ and c:\jdk1.3\jre\lib\security\. If you are interested to know more, you can reply back to the post :)

Regards,
Leon If you need additional help, you can email to me at zaoliang@hotmail.com I don't guaranty that I will be able to solve your problems but I will try my best :)
 
Hi Leon,

Thanks for the answer, but it need to work all the time on all computers.

I'll explain the situation:
We've an local intranet, where I would like to use applets to upload some files (read 'copy'). The files are copied to the server in a directory where everyone has the read and write permissions, security is not important. And in the mean time a row is written in a database where what files is located on the server.

All users will use an intranet site with the applet in it,
that's why it may not be an application.

How to make this work not only for testing, but also for using?

Thanks,
Charl
 
Hi Charl,

I suggest that you seperate this program to use servlets and applets instead of pure applets. Reason being :-

1) It would be too troublesome using applets to save a file onto the server

2) It is not possible to connect to the db on the server using applets


So what you can do is to get your applet connected to your servlet using streams. Send the file over to the servlet. The servlet would then insert a record into the db and save the file into the appropriate directory. This way, there is no need to change or set any security/permissions at all :)

Regards,
Leon If you need additional help, you can email to me at zaoliang@hotmail.com I don't guaranty that I will be able to solve your problems but I will try my best :)
 
Hi again,

I might be wrong in the previous post as in to that you do not have to set/change any security/permissions because no matter how, your applet still have to access your local pc's files in order to send them over to the servlet.

I have not actually done this before (sending of files) but it should be able to work since you are able to set the type of data transfer for the connection between the applet and servlet.

You might have to do more research on this part :)

Regards,
Leon If you need additional help, you can email to me at zaoliang@hotmail.com I don't guaranty that I will be able to solve your problems but I will try my best :)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top