File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

PDF display in JSP

 
Nivan scorp
Greenhorn
Posts: 23
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
I need to display a pdf document within an iframe in a JSP page.
The pdf is in the form of byte array.

Any clue on how this can be achieved?

Thanks,
Nivan.
 
Horatio Westock
Ranch Hand
Posts: 221
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You could create a servlet to stream the blob data.

e.g. http://yoursite/fileservlet?id=5

Then have that as the source of your iframe. Basically the servlet implementation would simply query for the blob then direct the stream from the backend to the servlet output stream. If you search the web for "jsp image blob" or something similar, you should be able to find some sample code. Remember also to consider things like content-type and cache headers.

Alternatively I think there are probably some taglibs to help with this, but personally I prefer option 1.
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic