aspose file tools*
The moose likes Java in General and the fly likes Programmatic download of a file on Web server Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Java in General
Bookmark "Programmatic download of a file on Web server" Watch "Programmatic download of a file on Web server" New topic
Author

Programmatic download of a file on Web server

Manohar Kumar V
Greenhorn

Joined: Dec 29, 2010
Posts: 4
Hi,
I am having some files on IIS web Server which I want to download using javascript/JSP or batch script.For example I am having a file with url http://10.1.25.147/repapp/20101229/bal.txt .
When I open the file in browser it ask me interactively to save the file.What I want is that it should download this file to client pc using some script.

Thanks
Paul Clapham
Bartender

Joined: Oct 14, 2005
Posts: 18987
    
    8

Manohar Kumar V wrote:When I open the file in browser it ask me interactively to save the file.What I want is that it should download this file to client pc using some script.


Yes, that's how it works. The server can't force the user to store the file on their computer, that would be a serious violation of the user's security.

It's certainly possible for the user to run a script on their machine to download and store the file. Or the user could just agree to that prompt and download the file anywhere they liked. But you asked in the JSP forum, which suggests that you want the server to force the download. You also asked about Javascript, which doesn't have any access to the client computer's file system. (That's also to prevent security violations.)
Manohar Kumar V
Greenhorn

Joined: Dec 29, 2010
Posts: 4
Hi,I will tell you my motive.I want to download the files from the server programatically and then ftp these file to a different host for further processing.I want to do it programatically because the end user does not want to download files individually and then upload it to ftp server

Thanks
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61766
    
  67

Your reasons for wanting to do this are not going to change the fact that you cannot. Imagine the security nightmare if any website could just write files to your filesystem without you knowing.


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Paul Clapham
Bartender

Joined: Oct 14, 2005
Posts: 18987
    
    8

As I said before, you could certainly write a script which downloaded each file to a work directory and sent it via FTP to the FTP server. Then you would run that script on the client machine.

However that has nothing at all to do with JSP, so your post is off-topic here. If you want to continue the discussion along those lines, let us know and we will move the post to a more suitable forum.
Manohar Kumar V
Greenhorn

Joined: Dec 29, 2010
Posts: 4
HI,
I want to carry on the discussion.i just want to accomplish this task in java or its related technologies.You can please move it to other suitable forum.
thanks
Paul Clapham
Bartender

Joined: Oct 14, 2005
Posts: 18987
    
    8

Okay. So, you want to download a file (via HTTP) from Server A, and then upload it (via FTP) to Server B. And you prefer to use Java for this task. I will move this to Java in General, then.
Manohar Kumar V
Greenhorn

Joined: Dec 29, 2010
Posts: 4
Yes that is what I exactly want.Can anyone help me in this?

Thanks
Rob Spoor
Sheriff

Joined: Oct 27, 2005
Posts: 19785
    
  20

Downloading can be done in many ways. Using java.net.URL is the easiest unless there is some form of authentication present. Apache Commons HttpClient or another 3rd party library will then be better.

For uploading I suggest Apache Commons Net or JvFTP.


SCJP 1.4 - SCJP 6 - SCWCD 5 - OCEEJBD 6
How To Ask Questions How To Answer Questions
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Programmatic download of a file on Web server