Sending a .PDF file to the browser via a servlet

N

N. Boucher

Hi,

I have a WEB application that returns a list of .pdf documents based
on a search.

The user can selected a document by clicking on a link in the browser.
A servlet is then called to retrieved the .pdf document from the
backend storage and displayed it in the same browser window.

Below is a sample of the code I used. The problem is that the title
displayed in the browser (I am using I.E 6) is the url of that link
(for example: http://localhost/ABC/displayDoc.do?...0-1-0-^ALICE+M.+LEON417211000012285108.91)

I do not want the URL to be displayed in the browser title, In my code
I am trying to set the title to test.pdf...but it doesn't work.

Any idea what I am doing wrong?

=======================================
....
....
response.setContentType("application/pdf; name=\"test.pdf\"");
response.setHeader("Content-Disposition","
inline;filename=\"test.pdf\"");
response.setContentLength(DataBytes.length);
OutputStream out = response.getOutputStream();
out.write(DataBytes, 0, DataBytes.length);
out.flush();
out.close();
....
....
=======================================

Thanks, Nadine
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,054
Latest member
TrimKetoBoost

Latest Threads

Top