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 Downloading a document. 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 "Downloading a document." Watch "Downloading a document." New topic
Author

Downloading a document.

prasanth chiru
Greenhorn

Joined: Mar 14, 2004
Posts: 16
Hi,
I am developing a web site in which we have a button "Download" in a document, which downloads that document and stores on the clients machine. If anybody has done this earlier or anybody has idea about this please help me.
Thanks
lokesh reddy
Ranch Hand

Joined: Sep 15, 2000
Posts: 66

Well, if u want to download a document to the client machine u have to use multipart mime type. It takes a long time to explain all about that. The best thing you can do is go to http://www.servlets.com and from there just download com.oreilly.servlet package and in that package you can find MultipartResponse class. Just go through that class and check it out.
You can use this class with out knowing much about it, but as a developer i think it would be nice to go through the class and understand the functionality.
I hope this info will be useful to you.
Lok.
prasanth chiru
Greenhorn

Joined: Mar 14, 2004
Posts: 16
Hi lokesh,
Thankyou very much for the immediate reply. I am just opening the site you have given. If I have any doubts further regarding this, I will contact you.
Thanks once again.
Manjunath
prasanth chiru
Greenhorn

Joined: Mar 14, 2004
Posts: 16
Hi lokesh,
I have downloaded the code of oreilly and used it in my -program for downloading. The code is like this.
MultipartResponse multi = new MultipartResponse(res);
multi.startResponse("text/plain");
out.println("On your mark");
multi.endResponse();
try { Thread.sleep(1000); } catch (InterruptedException e) { }
multi.startResponse("text/plain");
out.println("Get set");
multi.endResponse();
multi.finish();
I am getting the dialog box asking for the options "want to open in the current locatio" or " save the content to disk". If I select a particular option, the class file of this progarm is getting downloaded. If I want to download a figure or some text, where should I mention it. Can you pleasea give me some program for that.
Thank You.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Downloading a document.
 
Similar Threads
Java Program to Convert Oracle database to a single SQL file.
Downloading the document
Searching a XSL-file to transform docbook.xml to word.xml or openoffice.xml
Namespace using Axis
Display byte[] in browser