How do i use a web-hosted file as a regular local file?
Hi all!
I'm pretty new to JAVA and right now I'm writing a simple Applet where i need to store some data to a file.
I'm using the NetBeans IDE (NB) and in my project folder I created a simple .txt-file to write to, this works when I
run the .java file in NB but not when I generate an HTML-file which embedds the applet. So my question is, can you
work with a file resource this way when it comes to Applets? If not, how do I work with a web-hosted file (URL) to read
and write in the same way as with local files?
//OriginalUtter
Re: How do i use a web-hosted file as a regular local file?
It would need to be a signed applet if you want to be able to write to something on the client system.
Re: How do i use a web-hosted file as a regular local file?
Quote:
Originally Posted by
Tolls
It would need to be a signed applet if you want to be able to write to something on the client system.
I just need to write to the server, how do I do that?
/OriginalUtter
Re: How do i use a web-hosted file as a regular local file?
Ah, sorry, completely misread that!
OK, here's a little thought experiment for you.
Can you write to a file you can only access via http?
Once you answer that then you have the answer to your question.
Re: How do i use a web-hosted file as a regular local file?
You need a hand from a servlet to implements something like this. A servlet can access the files and modify them to your need. So make your applet to call the servlet and ask it to perform some task related to the file that you want to modified on the server.
Re: How do i use a web-hosted file as a regular local file?
Maybe it's easier to understand what I'm after if I explain a little more detailed about my problem.
The thing is that I have developed an Applet which i intend to embed in a webpage. This applet
allows users to enter strings and hit a 'send' button. This is where I want to collect the input string
and store it somewhere where I can read from later.
The applet it pretty much done except for the storing of input strings,
what is the smoothest way to do this?
Some guys have mentioned Servlets here, is that the best way to go?
If so, where do I start, what do I need to do? What is a Servlet?
//OriginalUtter
Re: How do i use a web-hosted file as a regular local file?
You could use PHP.
Essentially, if you want to store it on the web, then you need some code on the site the applet came from (applet security rules etc) that will accept the data and store it. It doesn't matter what that code is written in.