Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

download file using OutputStream from Servlets

 
ahmed yehia
Ranch Hand
Posts: 424
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I want to download a file from a web app using a Servlet and then save the file with its original name and extension, currently Im using ServletOutStream to write data to the response.

The file was successfully downloaded but it's got the Servlet name from which it came from.

I think that could be normal to not identify the file or its extension cause the Servlet is just writing bytes to the stream.

here is the code I use in Servlet:
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64683
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Look up the content-disposition response header.
 
ahmed yehia
Ranch Hand
Posts: 424
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Bear Bibeault, it does what I wanted to do.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic