• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Liutauras Vilda
  • Bear Bibeault
  • Junilu Lacar
  • Martin Vashko
Sheriffs:
  • Jeanne Boyarsky
  • Tim Cooke
  • Knute Snortum
Saloon Keepers:
  • Ron McLeod
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
Bartenders:
  • Scott Selikoff
  • salvin francis
  • Piet Souris

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

 
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,
 
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.
 
Rancher
Posts: 43011
76
  • 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.
 
Always! Wait. Never. Shut up. Look at this tiny ad.
Java file APIs (DOC, XLS, PDF, and many more)
https://products.aspose.com/total/java
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!