title: How to do file I/O with a servlet running on Tomcat
body: <p>I am writing a Java servlet, using Tomcat as the container, which creates and serves PDF files to the end-user. Currently the PDF files are created in-memory and written out as a response to a POST.</p>
  
  <p>I would like to change this up somewhat so that the PDF files are written to disk (so they can be served up again later). I am having trouble locating a suitable "how-to" for doing this.</p>
  
  <p><strong>How can I configure my servlet to write to and read files from a directory server-side?</strong> From what I've read, I think I need to locate this directory somewhere outside where my "exploded webapp" lives in <code>$CATALINA_BASE</code> for security reasons, and I need to use a <code>Context</code> or somesuch.</p>