Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7544993
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T08:48:57+00:00 2026-05-30T08:48:57+00:00

I have a bean with the raw bytes of a PDF that is generated

  • 0

I have a bean with the raw bytes of a PDF that is generated at the user’s request. I want to display this PDF to the user without really persisting the PDF file on my server.

In my jsp I have tried tags like

<object data="#{bean.pdfBytes}" type="application/pdf" ></object>
<object type="application/pdf" width="600" height="400">
    <h:outputFormat value="#{bean.pdfBytes}" escape="false"/>
</object>

but this fails terribly. Any help would be appreciated. Thanks in advance.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-30T08:48:59+00:00Added an answer on May 30, 2026 at 8:48 am

    I want to display this PDF to the user without really persisting the PDF file on my server.

    Write it to the output stream of the response. Let’s assume that you’re using iText to generate the PDF, pass the response’s output stream to PdfWrter#getInstance().

    public void download() throws IOException {
        FacesContext context = FacesContext.getCurrentInstance();
        HttpServletResponse response = (HttpServletResponse) context.getExternalContext().getResponse();
        response.setContentType("application/pdf");
        response.setHeader("Content-Disposition", "inline; filename=\"" + filename + "\"");
    
        Document document = new Document();
        PdfWriter writer = PdfWriter.getInstance(document, response.getOutputStream());
        document.open();
        // Build document.
    
        context.responseComplete();
    }
    

    This will however display the PDF in its entirety in the browser. If you want a Save As dialogue, just change the inline part in the header to attachment. Or if you really want to have it embedded in an <object>, then you’d need to create a servlet and do the above response job inside the doGet() method and finally let <object>‘s URL point to that servlet.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

i have bean that contain method [void return] and want access to this bean
I have a bean that i want to inject with a named list using
I have a bean that extends this txProxyTemplate and inside it, this method orderUpdateOverseer
I have an action bean in my stripes application. The default handler/method will display
I have a MDB (Message driven bean) that receives messages with String which represent
I have content stored as raw text in a database that I show in
I have this little credit card validation program where the user has to input
I have an application that stores a collection of objects in the user settings,
I have Java bean class and I want to sort list of these beans
Assume that we have Spring bean UserController with singleton scope. All my further reasoning

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.