Get your CodeRanch badge!*
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

Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
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: 12671
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:

Java Resources at
I agree. Here's the link:
subject: Serve an off-site page
Similar Threads
Connecting to Unix via Windows
uploads on Tomcat hosting
uploading files with java
File IO in EJBs
Problem in accessing request object in child frames.