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 Downloading a document. Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of OCA/OCP Java SE 7 Programmer I & II Study Guide this week in the OCPJP 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.