Gene Parmesan
Gene Parmesan

Reputation: 102

Passing PDF with servlets

I am sending a request to a servlet that is viewed something like http://url:8080/getDocument?docName=doc.pdf I am not too sure how the servlet that sent out the request will handle the PDF file when returned and then send the response back to my web page for the user to then just download or save.

I already have code that sends back XML documents and that is handled properly. Would I be doing a similar method?

1) How does a servlet send a pdf file over the network?

2) How does the receiving servlet handle the pdf?

3) After receiving the servlet how can I pass that on to the user to download or view?

Upvotes: 2

Views: 930

Answers (1)

richardtz
richardtz

Reputation: 4993

If the response you are sending is a pdf document you should add

response.setContentType("application/pdf")

in your servlet code.

Upvotes: 1

Related Questions