Results 1 to 4 of 4
  1. #1
    venkat6134 is offline Member
    Join Date
    Jun 2013
    Posts
    2
    Rep Power
    0

    Default how to link pdf files with in Jsp, to view in web browser?

    Hi all,

    I want to display PDF's in browser by using Jsp.

    i wrote normal <a> tag, when i run that JSP, the Anchor Text is showing with the link, but when i click that link, it is showing HTTP status -404.

    Please give me any idea to resolve it.

  2. #2
    gimbal2 is offline Just a guy
    Join Date
    Jun 2013
    Location
    Netherlands
    Posts
    3,083
    Rep Power
    4

    Default Re: how to link pdf files with in Jsp, to view in web browser?

    Status 404 is resource not found, so your link path is not correct. Simple reasoning right, you could have googled the status code and figured it out yourself.

    Where are you storing the PDFs, and what link are you generating?

  3. #3
    venkat6134 is offline Member
    Join Date
    Jun 2013
    Posts
    2
    Rep Power
    0

    Default Re: how to link pdf files with in Jsp, to view in web browser?

    Pdf's are in web-inf folder and in root directory of Project. And am giving absolute path for Anchor tag for both, but it is not showing..

    I think, in pdf files, pdf name contain spaces. This space is showing on browser as %20. Because of this, it wont work.

    How to remove spaces in filename, if it is so?

  4. #4
    gimbal2 is offline Just a guy
    Join Date
    Jun 2013
    Location
    Netherlands
    Posts
    3,083
    Rep Power
    4

    Default Re: how to link pdf files with in Jsp, to view in web browser?

    Its the browser that has to download the PDF file. The browser does not know anything about your server, so putting files in the WEB-INF folder and setting an absolute path to them is not going to work. This should be obvious to you by the way - when developing web applications you have to understand the difference between the client and the server.

    You have to put the PDF in a place where it can be reached through a HTTP GET request, much like your JSP, CSS and JS files. If you don't want to/can't do that, you will have to create a servlet which can stream the file from the server's filesystem to a HTTP response. Using BalusC's file servlet can help a lot:

    The BalusC Code: FileServlet

Similar Threads

  1. Replies: 0
    Last Post: 05-12-2013, 07:17 AM
  2. Displaying The Content of Doc files in Web Browser
    By mitesh1984_agrawal in forum Java Servlet
    Replies: 0
    Last Post: 04-15-2010, 08:41 AM
  3. can we view .dll files??
    By freddieMaize in forum Advanced Java
    Replies: 6
    Last Post: 06-19-2008, 07:33 AM
  4. Unable to view applets on a web browser
    By thejdev in forum Java Applets
    Replies: 2
    Last Post: 03-04-2008, 06:26 PM
  5. Create view of files in java-Swing
    By Albert in forum AWT / Swing
    Replies: 1
    Last Post: 07-06-2007, 06:06 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •