Sign in to follow this  
Swattkidd

[java] Writing to a file at a URL help

Recommended Posts

Ok i am creating a chat type of program that reads info from a file and posts it, but the problem i am haveing is being able to write to the file. The file is located in my site so i can read from it by reading from a URL but im not sure how to write to the URL, like send what the person writes in the chat box to the file when they push enter...

Share this post


Link to post
Share on other sites
No im trying to write to it the way i read from it, by makeing a URL and then opening a connection with it, but im not very clear on that, right now im asking how i could do that. I dont want to make it a networked chat program yet. I just want it so that a person opens it up and it displays what the last person wrote (because it displays whats in the txt doc) and then they can type, push send, and now when another person opens it, they can see what that person wrote (because its stored in the txt doc)

Share this post


Link to post
Share on other sites
Writing to the file that is on the server side should be the responsibility of an (web) application residing on that server. If you want to write to a file from remote code, you have to require the necessary permissions in a .policy file, and that can be a pain to configure and make work. I suggest you write a Servlet or something that deals with the writing, and let it receive as parameters what needs to be written on the file. Delegate different responsibilities to different classes in your architecture, making your system as 'loose coupled' as possible.

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
If you were to connect to the server via ftp and modify the file. The client would also need to have the username + password data. Thus, for security reasons would be a very bad idea. Simple decompiling of your application would reveal everything since, java is so easy to decompile anyone could do it.

Connect to a server, servlet, use a post() or get() statement for PHP to handle. and let the server deal with the modifying of the file.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this