• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

How jsp and a pdf document displayed in the same browser?

 
Kevin Zhang
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I need to display a pdf document within a frame in a JSP page.

In this JSP page, the left frame is a navigation menu.

The right frame is pdf content.

I use struts 1.3 and tiles to implement frames.

To generate pdf ,I use itext.

Here is the sample code

public ActionForward doGenerateLeterPDF(ActionMapping mapping, ActionForm form, HttpServletRequest req, HttpServletResponse response) throws WebException {
try{
Document document = new Document();
ByteArrayOutputStream baos = new ByteArrayOutputStream();
PdfWriter writer = PdfWriter.getInstance(document, baos);
document.open();
document.add(new Paragraph("Hello World"));
document.close();

response.setContentType("application/pdf");
response.setContentLength(baos.size());
ServletOutputStream out = response.getOutputStream();
baos.writeTo(out);
}catch(Exception e)
{
logger.error("Exception: " + e);

}

return null;

}

However, after I execute this action class, the pdf displayed in full screen

My request is pdf content only staying in one frame

Any clues on how to implement this?

Thanks,
 
kapil munjal
Ranch Hand
Posts: 298
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am also facing the same issue. Please provide some link or tell us how to do it.
 
Ulf Dittmer
Rancher
Pie
Posts: 42967
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The code shown above needs to be executed when the URL of the frame is accessed, not when the URL of the page itself is accessed.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic