Q:

How to return a non-editable PDF as a response?

I have a URL:
http://www.irs.gov/pub/irs-pdf/fw4.pdf
It contains an editable PDF. I have make it non-editable. I did so and kept it in the temp directory of a folder. Now i want to send the non-editable PDF as a response, when the user clicks this url, he must get the non-editable pdf. This is what I have done till now:
String strDirectoy ="C:\\Temp";
boolean success = (
    new File(strDirectoy)).mkdir();
    if (success) {
        System.out.println("Directory: " 
        + strDirectoy + " created");
    }  
PdfReader reader = new PdfReader("http://www.irs.gov/pub/irs-pdf/fw4.pdf");//C:\\fw4.pdf
PdfStamper stamp2 = new PdfStamper(reader, new FileOutputStream("C:\\Temp\\Flattened.pdf"));
AcroFields form2 = stamp2.getAcroFields();
stamp2.setFormFlattening(true);
stamp2.close();

Now i need to delete the temp folder as if it never existed and return the non-editable PDF as the response for the above specified URL.
How can i do this?

A:

Write a Servlet.  
Flatten your pdf in a temporary file (using the
createTempFile()  and deleteOnExit() methods of java.io.File).
Use the setContentType of the HttpServletResponse to set the MIME type
of the pdf. 
Write the contents of the temporary pdf file to the
outputstream of the http response

