HELP!How to get a text file from a web server and save it on local machine.

Our under-developent web system is global. Our clients should be able to search data from the server-side database and then after get the resultset, they also should be able to save these data as a text file on their local machine by just a click. Of course, before they click the OK button, they should navigate in the directories under their local drives and choose under which directory they want to put the file, and then provide a file name. The data retrieval part of this program is not a problem to me, my trouble is: I could NOT find a way to be able to navigate the local machine's drives. Any suggestion is definitely welcome.

[652 byte] By [huangjjing] at [2007-9-26 2:00:30]
# 1

if the ok button is a link.

And at the server side, you save the txt file to a ftp server, the link points to the txt file on the ftp server.

Then when user clicks the link, will the broswer display a save dialog, which is the one you see when you download some files from www?

Just suggestion

tulip_ye at 2007-6-29 8:39:42 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 2

The problem is that when a text file is sent to a browser, it will generally display the text file in the browser, depending on the type of browser of course.

You need to set the Content-disposition header that tells the browser to dowload the file, this will open the typical "File Save As" dialogue in the browser. See the following link for more detailed information, or search the JDCs for "Content-disposition".

http://www.javaworld.com/javaworld/javatips/jw-javatip94.html

-Derek

beattris at 2007-6-29 8:39:43 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 3

Send back the search results from server to client browser using the mime type application/octet-stream

You can do this by setting the content-type header in the HTTP response.

That will cause the browser to pop up the 'Save As' dialog box using which the user can navigate through the local file system and choose a folde to save the file into.

I have assumed you are talking about HTTP based web application accessed using browser.

neville_sequeira at 2007-6-29 8:39:43 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 4
Thanks very much, tulip. Do you have any idea if I can save the file directly onto the local drive instead of using a pumped up Save As... dialog? Because the VB version of our system performes like this.Thanks again.Jing
huangjjing at 2007-6-29 8:39:43 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 5
I believe the website the Derek provides is what I am looking for. Thanks.Jing
huangjjing at 2007-6-29 8:39:43 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...