How do I display pdf doc in browser using jsp - no servelet

Discussion in 'Java' started by novice via JavaKB.com, Feb 25, 2005.

  1. Please help me.

    I am a novice at jsp and java. i need to display a pdf file in browser.
    Even though I set contentType to "application/pdf", i see garbage on the
    screen.

    Can some one please help me or suggest some ideas?

    All help will be greatly appreciated.

    Thanks!!

    --
    Message posted via http://www.javakb.com
    novice via JavaKB.com, Feb 25, 2005
    #1
    1. Advertising

  2. novice via JavaKB.com

    Oscar kind Guest

    novice via JavaKB.com <> wrote:
    > I am a novice at jsp and java. i need to display a pdf file in browser.
    > Even though I set contentType to "application/pdf", i see garbage on the
    > screen.
    >
    > Can some one please help me or suggest some ideas?


    Use a servlet. JSP pages are generally only suitable for text results, and
    PDF is not. In the servlet, set the content type on the response object.


    --
    Oscar Kind http://home.hccnet.nl/okind/
    Software Developer for contact information, see website

    PGP Key fingerprint: 91F3 6C72 F465 5E98 C246 61D9 2C32 8E24 097B B4E2
    Oscar kind, Feb 25, 2005
    #2
    1. Advertising

  3. I REALLY need to display pdf doc without using servelets. I don't create
    the pdf docs. These are existing docs.

    Please someone help!!

    --
    Message posted via http://www.javakb.com
    novice via JavaKB.com, Feb 28, 2005
    #3
  4. novice via JavaKB.com

    Dotty Guest

    "novice via JavaKB.com" <> wrote in message
    news:...
    > Please help me.
    >
    > I am a novice at jsp and java. i need to display a pdf file in browser.
    > Even though I set contentType to "application/pdf", i see garbage on the
    > screen.
    >
    > Can some one please help me or suggest some ideas?
    >
    > All help will be greatly appreciated.


    do you have a pdf helper application, or a pdf plugin?
    Dotty, Feb 28, 2005
    #4
  5. novice via JavaKB.com

    Noah Fiedel Guest

    novice:
    You wrote that you are using JSP. Did you know that JSPs are compiled
    into Servlets? Any application server / Servlet Container that can host
    JSPs should be able to host vanilla Servlets just fine.

    Your handle is "novice" and you're posting to the
    comp.lang.java.programmer group, not the "help" group. Oscar was giving
    you good advise. If you want to produce PDFs, you should do it with a
    Servlet - that's the typical / standard way to produce PDFs over the
    web using Java.

    I just re-read your original post and can inerpret it two different
    ways:

    1. You already have static files of PDFs on your web server.
    2. You already have data files you wish to use to create PDF files.

    If #1, then all you need to do is somewhere in your JSP create an HREF
    link to the PDF files and let your web server serve them. I don't see
    how / why you would serve static PDFs *thru* a JSP.

    Good luck,
    Noah
    Noah Fiedel, Feb 28, 2005
    #5
  6. Noah, Oscar, Dotty - Thank you for your responses.

    Noah - Yes I already have static files but they are not located in the www
    path. the files are in a data directory. I can search and display the file
    list from that directory but the webserver does not recognize the datadir.

    So how would i display the file that is not in the webpath?


    Heeeeeelp

    --
    Message posted via http://www.javakb.com
    novice via JavaKB.com, Mar 1, 2005
    #6
  7. Anyone??????

    How do I display a file from a dir that is not in the www path?
    A pdf file?

    --
    Message posted via http://www.javakb.com
    novice via JavaKB.com, Mar 2, 2005
    #7
  8. novice via JavaKB.com

    Noah Fiedel Guest

    Novice,
    You're posting to the comp.lang.java.programmer group - a group
    for serious java questions. Your question is far more related to
    beginning web hosting / web mastering.
    Here are some answers for you, and please don't ask about JSP
    again - everyone has already told you that it doesn't make sense.

    1. If it's a UNIX machine, create a symbolic link from within
    your www path and to the pdf files or directories.
    2. Create a script (can be done in windows, macos, unix, etc)
    that copies the pdfs to an appropriate location in your www root. You
    can run this manually, or set-up a recurring task (windows) or cron-job
    (unix/macos)
    3. Learn how to properly configure your web server, and you
    should be able to serve-up pdfs from anywhere on your system by making
    a second document-root for only the pdfs, with a directory alias (I
    know this works with Apache, and am pretty sure it works in Microsoft
    IIS).

    Good luck to you.
    Noah Fiedel, Mar 2, 2005
    #8
  9. novice via JavaKB.com

    borgymanotoy

    Joined:
    Jun 5, 2009
    Messages:
    1
    Display PDF Files

    hello there,

    you might want to try this sample line...

    <iframe src="URL_OF_PDF_FILE_HERE.pdf" style="width:800px;height:600px;border:1px solid #000000;z-index:1;" />

    you can change the src value to the address of your pdf file [i.e. src="pdfs/sample.pdf"]

    goodluck.
    borgymanotoy, Jun 5, 2009
    #9
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Edward A Thompson
    Replies:
    2
    Views:
    625
    Tim Jowers
    Jul 14, 2003
  2. Matt
    Replies:
    3
    Views:
    499
    Tor Iver Wilhelmsen
    Sep 17, 2004
  3. freshAtThis via JavaKB.com

    How do you call a servelet from jsp?

    freshAtThis via JavaKB.com, Mar 1, 2005, in forum: Java
    Replies:
    6
    Views:
    9,152
    Ryan Stewart
    Mar 5, 2005
  4. YiMkiE
    Replies:
    0
    Views:
    333
    YiMkiE
    Jul 6, 2006
  5. Jackie Lee
    Replies:
    4
    Views:
    592
    Juha Laiho
    Jul 9, 2006
Loading...

Share This Page