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 6000865
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T00:45:18+00:00 2026-05-23T00:45:18+00:00

How do I open a PDF document from JSP? I have many links to

  • 0

How do I open a PDF document from JSP? I have many links to PDF files. In Eclipse, when I click on the link, the PDF opens in PDF reader. But in a webbrowser like Firefox and Chrome, nothing happens.

I am generating the links to PDF files as F:\....\...pdf the following way:

<%
    while (iter.hasNext()) {
        element = iter.next(); 
        bookName = getBookName(element);

%>
        <ul>
            <li><a href="<%=element %>"><%=bookName %></a>
        </ul>
<% 
    }
%>

How is this problem caused and how can I solve it?

  • 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-23T00:45:19+00:00Added an answer on May 23, 2026 at 12:45 am

    The links have to point to an URL, not to a local disk file system path or something. The average webbrowser doesn’t swallow this due to security restrictions. And even then when it did, it would not work in production environment when the webbrowser runs at a physically different machine than the webserver and thus doesn’t have access to F: disk at all.

    So, you should NOT use

    <a href="F:\....\...pdf">link</a>
    

    but you should rather use

    <a href="http://example.com/filename.pdf">link</a>
    

    or when it’s for example in the same folder of the current JSP file

    <a href="filename.pdf">link</a>
    

    If you cannot put the PDF file in your own web project, then you need to look for different solutions.

    • Add the external folder as another context of the servletcontainer.
    • Move the external folder into deploy folder of the servletcontainer.
    • Create a servlet which reads it from disk and writes it to response.

    You can find the above solutions in detail in the answers of the following questions:

    • Load images from outside of webapps / webcontext / deploy folder using <h:graphicImage> or <img> tag
    • Simplest way to serve static data from outside the application server in a Java web application
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I installed Acrobat Reader 9.0 last month, Each time I open a pdf document,
I have a iframe that i want to open pdf's into from a list
I have XPS files with header bookmarks. If you open the source document in
I'm trying to open a PDF document from a hyperlink to a certain page.
I want to open a PDF document at a specific page from the command
I have a requirement where there is a URL = http://www.example/Open.pdf Now from my
I have an application that serves artifacts from files (pages from PDF files as
I'm trying to link a pdf document from a static html file. What I'm
Is it possible to open a PDF from a website in Safari in order
Is it possible that when you have a webpage, when you open the PDF,

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.