Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Downloading a document.

 
prasanth chiru
Greenhorn
Posts: 16
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 66
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

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
Posts: 16
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 16
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic