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.
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
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
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.