File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Servlets and the fly likes Serve an off-site page Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Servlets
Bookmark "Serve an off-site page " Watch "Serve an off-site page " New topic

Serve an off-site page

Michael Mendelson
Ranch Hand

Joined: Dec 19, 2000
Posts: 73

Hi, all!
I would like to provide access to a page (a PDF document, actually) that located in a directory not accessible by Tomcat.
I imagine there is some way to set up a servlet to grab the contents of the file, and send it with the proper header.
Does anyone know how to do this offhand, or know of a better way?
(Ultimately my reason for wanting to do it this way is to share files with other apps on the server, AND to implement some access control for the files.)
William Brogden
Author and all-around good cowpoke

Joined: Mar 22, 2000
Posts: 13036
What you want is pretty simple - see any servlets book, including mine. The only things to watch out for are that you have to set the content type and (usually) the content length, and use a binary output stream, not a print writer.
author of:
I agree. Here's the link:
subject: Serve an off-site page
It's not a secret anymore!