Writing a file into an url location

Hello Everybody, Can anyone tell me how to write a file into an url location like " http://61.13.45.67:8080/contextname/ " . Thanks and Regards srikanta
[188 byte] By [srikanta] at [2007-10-3 3:11:01]
# 1
do you mean uplad a file ?
java_2006a at 2007-7-14 21:01:50 > top of Java-index,Java Essentials,Java Programming...
# 2
im not sure if its possible to write it to the location from another computer by just using the URL, but its definately possible if u have a java server running that takes the info from the client writing the file and then the server would right it to the wanted location
Futurisdom_Developera at 2007-7-14 21:01:50 > top of Java-index,Java Essentials,Java Programming...
# 3
YOu need to have something running there you accept what you are sending. Sych as a servlet, CGI or some server side program.If the URL is FTP URL then you will be able to upload provided that you have permissions to do so
LRMKa at 2007-7-14 21:01:50 > top of Java-index,Java Essentials,Java Programming...
# 4
Actually i don't want to upload.I want to create a new file there and write some content to that file. Thanks srikant
srikanta at 2007-7-14 21:01:50 > top of Java-index,Java Essentials,Java Programming...
# 5
Hi Thanks for ur replay. Actually this is not a FTP URL.its just a URL . Thanks Srikant
srikanta at 2007-7-14 21:01:50 > top of Java-index,Java Essentials,Java Programming...
# 6
Hi, Thanks for ur replay.Let u got the data from the client.then how u write the data to a file and save it in the perticular url location.Thanks&Regards Srikant
srikanta at 2007-7-14 21:01:50 > top of Java-index,Java Essentials,Java Programming...
# 7

There is no such thing as "just a URL". An absolute URL always contains a scheme part that describes the protocol to use for accessing that URL (HTTP in this case). Most HTTP servers do no support content creation on URLs by default.

The most common way to put content on an HTTP server is to use FTP to put the content in a place on the server the HTTP server looks at.

However, if you control the HTTP server, you could set it up to respond to PUT or POST requests in the way you want, possibly by using WebDAV.

Herko_ter_Horsta at 2007-7-14 21:01:50 > top of Java-index,Java Essentials,Java Programming...
# 8

came across the same problem.

(just an aside on the last reply -- the originator is not talking about an HTTP server (port 80 for apache httpd but rather a servlet container -- from port 8080 for Tomcat in the first post).

from an inspection of the API, this is what strikes me:

could construct a URI and pass that to a File constructor and use that in turn to construct a FileOutputStream. Using the FOS, you could then write a file into a url (more precisely a URI location).

Haven't tried it myself, but this is what I suggested to a friend who was facing the same problem.

nikhilsilveiraa at 2007-7-14 21:01:50 > top of Java-index,Java Essentials,Java Programming...
# 9

What you are trying to do is, in fact, uploading a file.

Now the last thing you want is for anyone to be able to write files onto your web server, so there's no built-in capacity to write to one. There is, in fact, a "PUT" transaction type defined in HTML but servers never implement it directly, in a way that allows you to write arbitary files to the server. It would be a security nightmare.

What you need to do is to have a Servlet which accepts uploaded data, using either a PUT or a POST transaction type and stores them sensibly. The servlet controlls how much data can be stored where.

Then it's easy enough to send data to that servlet.

malcolmmca at 2007-7-14 21:01:50 > top of Java-index,Java Essentials,Java Programming...