aspose file tools*
The moose likes JSP and the fly likes Saving File to Client Machine. Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » JSP
Bookmark "Saving File to Client Machine." Watch "Saving File to Client Machine." New topic
Author

Saving File to Client Machine.

Gillian Daniel
Greenhorn

Joined: Dec 09, 2003
Posts: 9
Hi all,
I recently posted about uploading files to the server from the client, now, I guess I techinically want to download files to the client.

The consultants on a big project basically want to be able to do this, and I am investigating how possible this would be. We are using Struts and Weblogic 8.1. I think it is probably impossible, but I don't want to sound too negative, and figured I don't really know everything, so should investigate.

We have an application, where users can import items to the database, and also export things from the database, to XML files.

Up until today, we had to make the users import and export things to and from files on the server. I have now managed to allow them to import files from their client, but have not sussed how to allow them to export files to their machine, without having to make them hit the mouse and select save as.

This is an acceptable solution if there is no other way, it is just that if we save tons of files to the server, then allow the user to save as, the server will eventually have lots of files on it that are not meant to be there.

The user inputs the file name, so I was wondering if there was anyway of downloading information to the file name submitted without save as?

Thanks,
Gillian
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61222
    
  66

export files to their machine, without having to make them hit the mouse and select save as.


No, there is no way to do this. Imagine the security implications if any web site could silently place files on the client.

You'd need something like a signed applet to be able to accomplish this. (Or an ActiveX control if you're tunnel-visioned into Microsoft).


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

Joined: Apr 14, 2004
Posts: 10336

Not without some client side code. If you didn't want the client to have to use the browser supplied method of downloading files you would have to implement another one yourself.

I'd start to think about some good way to clean up these temp files on you server instead and not bother too much about the "save as" stuff.

(unless its esential, and its an intranet site - in which case you could use FTP)
[ November 08, 2004: Message edited by: Paul Sturrock ]

JavaRanch FAQ HowToAskQuestionsOnJavaRanch
Gillian Daniel
Greenhorn

Joined: Dec 09, 2003
Posts: 9
Thanks.
I didn't think it was possible (for the security reasons), but I just had to check, since the user is responsible for typing in the file name, or providing the file name I thought it just MIGHT be possible. But you have confirmed what I already thought, and I just wanted to make sure, before telling everyone it was impossible, and then finding out it was possible.

Thanks again,
Gillian
sksharma sharma
Greenhorn

Joined: Oct 08, 2004
Posts: 14
Hi I think u can do it by adding all the contents first in the stringbuffer and store it on the server and give the path of that text file to the hyperlink download
but this solution has a drawback that every time there we are making ,whether the client download the page or not.
you can solve it if u save the text in the stringbuffer to the disk only when the client click the download link

If i am wrong then please sugest me
BY
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Saving File to Client Machine.