简体   繁体   中英

Retrieve Blob data (pdf) using java in Google app Engine

I have a database in which there is one field with Blob data. I want to put the download link on this file. i have used

resp.setContentType("application/pdf");
resp.getOutputStream().write(content.getBytes());

to get the pdf file. I am able to get the file but it gets downloaded on the page in which this code is written. I want to put the link with file name and on clicking the link i want to download this file.

I would simply add a target="_blank" attribute in your download link:

<a target="_blank" href="http://pathtothedownloadservlet">Download this pdf</a>

or, as said by Nick, use the Content Disposition like this:

resp.setHeader( "Content-Disposition", "attachment;filename=test.pdf");

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM