opening a pdf file using java web application

R

raj

HI,
can anyone please help me out to solve this problem

i developed a webapplication and deployed in tomcat server.
in my web application i need to open a pdf file which is located in my
machine and not in tomcat server.so when i click on the pdf link i
should be able to open the pdf.

onClick="window.open('C:/rajesh/abc.pdf
','mywindow','width=400,height=200,toolbar=yes,
location=yes,directories=yes,status=yes,menubar=yes,scrollbars=yes,copyhistory=y
es,
resizable=yes')"

this is the code i had written in my jsp,onclicking the link i am not
able to open the pdf as it is not in the scope of the webapplication,

now i had copied the pdf file to apache-tomcat-6.0.16\webapps\myproject
\abc.pdf

when i change the above function to this its working and opening the
pdf
onClick="window.open(http://localhost:8080/myproject/abc.pdf
','mywindow','width=400,height=200,toolbar=yes,
location=yes,directories=yes,status=yes,menubar=yes,scrollbars=yes,copyhistory=y
es,
resizable=yes')"


please anyone help me in open the pdf file which is located outside my
tomcat server.

Thanks in advance
 
A

Andrew Thompson

please anyone help me in open the pdf file which is located outside my
tomcat server.

Anything which is 'inside' your tomcat server is
available to the general public (assuming your server
allows it to be made public).

Anything 'outside your tomcat server is available
to you and your alone.

Files on the end-user's machine are available to the
end user, and only available to your web-app by
specifically requesting the file as specified by the
user (which requires jumping through a lot of
hoops).

So, where is this file you want to open? Is it on the
machine with the server, oir is it on the client machine?

If it is on the server, then the only rational option
is to include it in the servers normal file path that
is for 'files for serving to the general public'.

And as an aside, PDF's are (about) only good for
printing, why are you dumping them to a browser?
 
D

Dave Miller

raj said:
HI,
can anyone please help me out to solve this problem

i developed a webapplication and deployed in tomcat server.
in my web application i need to open a pdf file which is located in my
machine and not in tomcat server.so when i click on the pdf link i
should be able to open the pdf.

onClick="window.open('C:/rajesh/abc.pdf
','mywindow','width=400,height=200,toolbar=yes,
location=yes,directories=yes,status=yes,menubar=yes,scrollbars=yes,copyhistory=y
es,
resizable=yes')"

this is the code i had written in my jsp,onclicking the link i am not
able to open the pdf as it is not in the scope of the webapplication,

now i had copied the pdf file to apache-tomcat-6.0.16\webapps\myproject
\abc.pdf

when i change the above function to this its working and opening the
pdf
onClick="window.open(http://localhost:8080/myproject/abc.pdf
','mywindow','width=400,height=200,toolbar=yes,
location=yes,directories=yes,status=yes,menubar=yes,scrollbars=yes,copyhistory=y
es,
resizable=yes')"


please anyone help me in open the pdf file which is located outside my
tomcat server.

Thanks in advance
Tomcat can only serve from the application's docBase and the
subdirectories of the docBase. If the file is outside of that space, you
must first get the file (i.e. FileInputStream) and then serve from that
stream.
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,755
Messages
2,569,535
Members
45,007
Latest member
obedient dusk

Latest Threads

Top