jakarta ee – Open a Pdf File generated in java web Application
jakarta ee – Open a Pdf File generated in java web Application
You have to attach your file as a byte array to your response:
String serverHomeDir = System.getenv(CATALINA_HOME);
String reportDestination = serverHomeDir + /Reports/ + user + _ + church + _ + currdate + .pdf;
FileInputStream fis = new FileInputStream(new File(reportDestination));
// Fast way to copy a bytearray from InputStream to OutputStream
org.apache.commons.io.IOUtils.copy(fis, response.getOutputStream());
response.setContentType(application/pdf);
response.setHeader(Content-Disposition, attachment; filename= + reportDestination);
response.flushBuffer();