amit surana
amit surana

Reputation: 49

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.

Upvotes: 1

Views: 790

Answers (2)

systempuntoout
systempuntoout

Reputation: 74064

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");

Upvotes: 1

Nick Johnson
Nick Johnson

Reputation: 101139

You need to set the Content-Disposition header.

Upvotes: 0

Related Questions