Win a copy of Think Java: How to Think Like a Computer Scientist this week in the Java in General forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

code for file download

 
Udit Manektala
Ranch Hand
Posts: 30
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The code below fetches me the file I intend to download using the servlet but in the browser, the file is received (downloaded) as POTD ( with no file extension) instead of test.jar

 
Dave Wingate
Ranch Hand
Posts: 262
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
one possible solution would be to have users request:
http://your_site/test.jar

and map requests for test.jar to your POTD servlet.
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64827
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Investigate the "content-disposition" header.
 
Ben Souther
Sheriff
Posts: 13411
Firefox Browser Redhat VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
See the JspAndExcel example in the JSP FAQ section of this site for sample code that uses the Content-Disposition header to do this.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic