This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
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


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
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
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Download text file
 
Similar Threads
how to use citation style language?
how to create a link to download pdf file?
Setting up a file Download from my site
How to create text file through http using URL?
saving a file on local PC