JAVA: Set filename using setHeader()


Using the response.setHeader() method you can easy set the filename and extention as you like.



response.setContentType("image/jpeg");
response.setHeader(
"Content-Disposition",
"attachment;filename=MyFilename.jpg;"
);


If you are serving other fileformats, remember to change the content type.

Comments

Popular posts from this blog

How to create unicode files using VBA?