Help delivering pdf to user

W

Wendy S

I'm creating pdf files on a database server, and need to deliver them to a
logged-in user in a secure fashion. Currently, we create a directory on the
web server, and place the pdf and a .htaccess file that restricts access to
only the IP address that the request came from.

What options do I have to send a pdf to a browser without redirecting to its
location? I was thinking of forwarding the request to a Servlet which would
look in the session for the UserID and the requested report, then [?] stream
the pdf back to the browser.

I'm having no luck with Google, mostly because I don't know what I'm looking
for. I'm sure someone has done this already, so links are appreciated!
 
A

Andy Fish

yes that's all there is to it

just give the user a URL which invokes the servlet (presumably with enough
parameters that you know how to make the pdf or where to get it from.

then in the servlet implementation you just do something like:

response.setContentType('application/pdf');
OutputStream os = response.getOutputStream();
os.write (... the PDF data);
os.close();

that's untested but I'm sure it's close enough to give you the idea

Andy
 

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,756
Messages
2,569,535
Members
45,007
Latest member
OrderFitnessKetoCapsules

Latest Threads

Top