Granny's Programming Pearls
"inside of every large program is a small program struggling to get out"
JavaRanch.com/granny.jsp
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

download attachment  RSS feed

 
Nirmal JeyaChandra
Greenhorn
Posts: 25
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
In php we use
header("Content-Type: octet/stream");
header("Content-Disposition: attachment; filename=\"".$filepath."\"");

to get the download dialog box and to download, open, or save a file what about in java.
 
Scheepers de Bruin
Ranch Hand
Posts: 99
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Try this:
In the doGet or doPost method of you servlet


Where response is a javax.servlet.http.HttpServletResponse

I am not entirely sure how to do the filename bit, though...
 
Ulf Dittmer
Rancher
Posts: 42972
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
This article explains the process in greater detail.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!