Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

HttpURLConnection write to remote file  RSS feed

 
sam wootton
Ranch Hand
Posts: 100
2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello,

Thanks in advance for any help. I want to write to a file on a remote server (on my LAN). The file (download.txt) is on Ubuntu, and the Tomcat server on Windows.

I use HttpURLConnection code below. There are no errors or exceptions thrown, the response code is fine and yet the file isn't written to.

The apache logs show that it is hit (I think... time-stamp looked right and its from my windows IP)



But the file is never written to. Any ideas?



Regards, Sam

 
Tim Moores
Saloon Keeper
Posts: 3511
77
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
An HTTP server is not a file server. What kind of HTTP process sits at the remote end, and is prepared to accept incoming files? If you wrote it, post its relevant code.
 
sam wootton
Ranch Hand
Posts: 100
2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Tim Moores,

Thanks for your help.

Its just Ubuntu running apache2.

Regards, Sam
 
Tim Moores
Saloon Keeper
Posts: 3511
77
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Out of the box, httpd serves files (resources, strictly speaking), but doesn't accept them. Unless you install some module, or an active server component maybe based on PHP or Tomcat, it won't be able to accept incoming files.
 
sam wootton
Ranch Hand
Posts: 100
2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Tim Moores,

Thanks for your advice and help.

Okay, see conceptually I've got a bit of a gap. I didn't really think of the http / web server basics.

I guess maybe go down toe ftp route.

Regards, Sam
 
sam wootton
Ranch Hand
Posts: 100
2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Actually think I'm going to go down the scp route.

This library seems stable / used lots

http://www.jcraft.com/jsch/

<dependency>
<groupId>com.jcraft</groupId>
<artifactId>jsch</artifactId>
<version>0.1.53</version>
</dependency>

Regards, Sam
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!