Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Java > How do I display pdf doc in browser using jsp - no servelet

Reply
Thread Tools

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

 
 
novice via JavaKB.com
Guest
Posts: n/a
 
      02-25-2005
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
 
Reply With Quote
 
 
 
 
Oscar kind
Guest
Posts: n/a
 
      02-25-2005
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
 
Reply With Quote
 
 
 
 
novice via JavaKB.com
Guest
Posts: n/a
 
      02-28-2005
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
 
Reply With Quote
 
Dotty
Guest
Posts: n/a
 
      02-28-2005

"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?


 
Reply With Quote
 
Noah Fiedel
Guest
Posts: n/a
 
      02-28-2005
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

 
Reply With Quote
 
novice via JavaKB.com
Guest
Posts: n/a
 
      03-01-2005
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
 
Reply With Quote
 
novice via JavaKB.com
Guest
Posts: n/a
 
      03-02-2005
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
 
Reply With Quote
 
Noah Fiedel
Guest
Posts: n/a
 
      03-02-2005
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.

 
Reply With Quote
 
borgymanotoy borgymanotoy is offline
Junior Member
Join Date: Jun 2009
Posts: 1
 
      06-05-2009
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.
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Any recommended book for jsp and servelet? Jackie Lee Java 4 07-09-2006 05:39 PM
Any recommended book for jsp and servelet? YiMkiE Java 0 07-06-2006 09:31 AM
How do you call a servelet from jsp? freshAtThis via JavaKB.com Java 6 03-05-2005 01:51 AM
String[] files = {"a.doc, b.doc"}; VERSUS String[] files = new String[] {"a.doc, b.doc"}; Matt Java 3 09-17-2004 10:28 PM
MVC model for JSP/Servelet without using Struts Edward A Thompson Java 2 07-14-2003 05:40 PM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57