• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

File Downloads using servlets

 
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Problem downloading a file through the servlet.
The file download happens, but shows only 0 bytes as its content.
sample code of the setting of the headers is shown below:
response.setHeader("Content-Length",String.valueOf(fDownloadFile.length()));
response.setContentType("application/octet-stream");
response.setHeader("Content-Disposition","attachment;Filename=" + fDownloadFile.getName());

Please tell me if the reason for this not happening.
rgds,
Raghu
 
Ranch Hand
Posts: 74
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I don't know about the "Content-Disposition" header.
Don't you have to open the input stream of your file and write the bytes to the response output stream of the servlet yourself?
reply
    Bookmark Topic Watch Topic
  • New Topic