You need a servlet that looks like this:
public class PDFServlet extends javax.servlet.http.HttpServlet implements javax.servlet.Servlet {
private static final long serialVersionUID = 1L;
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
String pdfFileName = "tu-pdf.pdf";
String contextPath = getServletContext().getRealPath(File.separator);
File pdfFile = new File(contextPath + pdfFileName);
response.setContentType("application/pdf");
response.addHeader("Content-Disposition", "attachment; filename=" + pdfFileName);
response.setContentLength((int) pdfFile.length());
FileInputStream fileInputStream = new FileInputStream(pdfFile);
OutputStream responseOutputStream = response.getOutputStream();
int bytes;
while ((bytes = fileInputStream.read()) != -1) {
responseOutputStream.write(bytes);
}
}
}
You can also do it in a similar way with other FRAMEWORKS Web for Java, but since you did not specify any, I'll give you the most generic way to carry this out.