In my servlet, after doing some operations, I’m generating a PDF. Its in ByteArray.
I’m able to display that PDF in browser by doing,
- Taking
byte[]toInputStream - Writing it to
ByteArrayOutputStream - Then writing
ByteArrayOutputStreamtoServletOutputStream. - And then return null;
This will display the PDF in my current window, but Is it possible to display PDF in any specific JSP page ?
Because I want to put some buttons in the footer of that JSP at the same time while displaying pdf. In above way, whole window contains only PDF.
You can embed an
IFRAMEin your JSP page and set its dimensions to occupy the entire page except for the portion where you want to display the footer, and the footer would be part of your JSP. The IFRAME target/src would be the servlet that displays the PDF.Currently, you seem to be calling Servlet B from page A with some request parameters. You should call the new JSP from Page A with the same request parameters, and JSP page would build the target URL for the IFRAME and invokes servlet B which will process and return the PDF page.