File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Servlets and the fly likes Download text file Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Servlets
Bookmark "Download text file " Watch "Download text file " New topic
Author

Download text file

jack nick
Ranch Hand

Joined: Jan 11, 2001
Posts: 96
Hello there,
I need to download a text file which is created on the fly to a browser.
My Step
Take some input from the user via html
Query a database
Generate a text file
Send it to the client browser.
Am able to acheive all this. But the out put of this txt file comes on the browser itself whereas my requirements demand that this text file be stored at a user defined location open up the file browser.
Could any let me know how to overcome this situation
Regards
Jack
Andri G
Greenhorn

Joined: Oct 15, 2000
Posts: 4
Originally posted by jack nick:
Hello there,
I need to download a text file which is created on the fly to a browser.
My Step
Take some input from the user via html
Query a database
Generate a text file
Send it to the client browser.
Am able to acheive all this. But the out put of this txt file comes on the browser itself whereas my requirements demand that this text file be stored at a user defined location open up the file browser.
Could any let me know how to overcome this situation
Regards
Jack

Andri G
Greenhorn

Joined: Oct 15, 2000
Posts: 4
[sorry for my previous mistaken reply]
Hi Jack,
In your case, it is opened by the browser because client browsers
usually register for MIME text to be opened by itself (as with some other MIME type - html, images, etc).
So I think you have to change the extension (don't use .txt)
to some type unregister to browsers so default download dialog will show up (maybe ".dat"?).
Hope this may help,
Andri
Jason Menard
Sheriff

Joined: Nov 09, 2000
Posts: 6450
The other thing you could do is use jspSmartUpload from http://www.jspsmart.com/ . This will allow you to either download a file or a field from a database.
Jason
jack nick
Ranch Hand

Joined: Jan 11, 2001
Posts: 96
Thanks guys will check this out. One think for certain. I did try to send in .dat file instead of a .txt containing plain text but this opens in the browser.
Bye
Jack
 
Don't get me started about those stupid light bulbs.
 
subject: Download text file