Trying to access a directory outside docBase... is it possible ?

2009-12-15 Thread Ingo Gambin
Hi,

I am new to Tomcat and JEE, but a new job means to learn new things.

So right to my problem, wich I am sure is not too unusual, but I
couldn't really find a solution (via google) so far.

my directory structure looks as follows

/opt/document-repository  - mounted nfs-disk of an archiving system

/opt/Tomcat/webapps/myApp.war - my project deployment file

my webapp for now is just a bunch of servlets which, using
java.io.File..., have no trouble to read the archiving systems directory
structure listing to list all available archived pdf-files. With
servlets and some CSS I managed to build a little directory tree in the
browser output and linked the pdf-files to get opened (via adobe reader
plugin) in an iframe 

this basically works if the pdf-files I want to open are located in the
deployment directory.

but what I want to do is to access the pdf-files of the archiving disk.
it seems tho while the servlet java code {java.io...} CAN, tomcat CANNOT
access the pdf-files, which are stored there. And my projects deployment
directory and the archiving systems mount have to be separated, so I can
not mount the nfs into the deployment directory nor can I put my
application around the nfs-mount-directory

I stumbled over a hint about adding a 

  Context  docBase=/opt/documents path=/documents/

directive to the web.xml file, but I haven't had any luck with my
experiments so far, but then I realized that this would mean that I also
have to move my project directory which I can't.

So if there is any possibility to get this done (i am using linux incase
you haven't guessed already) I would be very glad if anyone could drop a
few lines to help me out.

Thanks in advance!


Ingo Gambin

Brilliant Vorsorge GmbH 
Worringer Str. 2-4 
D-40211 Düsseldorf 

Telefon:  +49 (0) 211 / 61793-0 
Mobil:+49 (0) 176 / 44 66 66 42
eMail:igam...@brilliant.de
PGP-Fingerprint:  D316 7343 EA4B 82C7 D96D  6917 3BF3 005A DA46 227F






signature.asc
Description: Dies ist ein digital signierter Nachrichtenteil


Re: Trying to access a directory outside docBase... is it possible ?

2009-12-15 Thread Pid

On 15/12/2009 13:46, Ingo Gambin wrote:

Hi,

I am new to Tomcat and JEE, but a new job means to learn new things.

So right to my problem, wich I am sure is not too unusual, but I
couldn't really find a solution (via google) so far.

my directory structure looks as follows

/opt/document-repository- mounted nfs-disk of an archiving system

/opt/Tomcat/webapps/myApp.war- my project deployment file

my webapp for now is just a bunch of servlets which, using
java.io.File..., have no trouble to read the archiving systems directory
structure listing to list all available archived pdf-files. With
servlets and some CSS I managed to build a little directory tree in the
browser output and linked the pdf-files to get opened (via adobe reader
plugin) in an iframe

this basically works if the pdf-files I want to open are located in the
deployment directory.

but what I want to do is to access the pdf-files of the archiving disk.
it seems tho while the servlet java code {java.io...} CAN, tomcat CANNOT
access the pdf-files, which are stored there. And my projects deployment
directory and the archiving systems mount have to be separated, so I can
not mount the nfs into the deployment directory nor can I put my
application around the nfs-mount-directory

I stumbled over a hint about adding a

   Context  docBase=/opt/documents path=/documents/

directive to the web.xml file, but I haven't had any luck with my
experiments so far, but then I realized that this would mean that I also
have to move my project directory which I can't.

So if there is any possibility to get this done (i am using linux incase
you haven't guessed already) I would be very glad if anyone could drop a
few lines to help me out.


What actually happens when you try to access the files?
Does the Tomcat process have sufficient rights to access that directory?


p


Thanks in advance!


Ingo Gambin

Brilliant Vorsorge GmbH
Worringer Str. 2-4
D-40211 Düsseldorf

Telefon:  +49 (0) 211 / 61793-0
Mobil:+49 (0) 176 / 44 66 66 42
eMail:igam...@brilliant.de
PGP-Fingerprint:  D316 7343 EA4B 82C7 D96D  6917 3BF3 005A DA46 227F







-
To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org
For additional commands, e-mail: users-h...@tomcat.apache.org



Re: Trying to access a directory outside docBase... is it possible ?

2009-12-15 Thread Ingo Gambin
Am Dienstag, den 15.12.2009, 15:01 + schrieb Pid:
 o right to my problem, wich I am sure is not too unusual, but I
  couldn't really find a solution (via google) so far.
 
  my directory structure looks as follows
 
  /opt/document-repository- mounted nfs-disk of an archiving system
 
  /opt/Tomcat/webapps/myApp.war- my project deployment file
 
  my webapp for now is just a bunch of servlets which, using
  java.io.File..., have no trouble to read the archiving systems
 directory
  structure listing to list all available archived pdf-files. With
  servlets and some CSS I managed to build a little directory tree in
 the
  browser output and linked the pdf-files to get opened (via adobe
 reader
  plugin) in an iframe
 
  this basically works if the pdf-files I want to open are located in
 the
  deployment directory.
 
  but what I want to do is to access the pdf-files of the archiving
 disk.
  it seems tho while the servlet java code {java.io...} CAN, tomcat
 CANNOT
  access the pdf-files, which are stored there. And my projects
 deployment
  directory and the archiving systems mount have to be separated, so I
 can
  not mount the nfs into the deployment directory nor can I put my
  application around the nfs-mount-directory
 
  I stumbled over a hint about adding a
 
 Context  docBase=/opt/documents path=/documents/
 
  directive to the web.xml file, but I haven't had any luck with my
  experiments so far, but then I realized that this would mean that I
 also
  have to move my project directory which I can't.
 
  So if there is any possibility to get this done (i am using linux
 incase
  you haven't guessed already) I would be very glad if anyone could
 drop a
  few lines to help me out.
 
 What actually happens when you try to access the files?
 Does the Tomcat process have sufficient rights to access that
 directory?
 
 

http://localhost:8080/myApp/PDFClient  - entry servlet and main form
http://localhost:8080/myApp/PDFViewer  - servlet loaded in IFrame 

ok when I click on a linked PDF 

e. g.   
a

href=http://localhost:8080/myApp/PDFViewer?file=document-repository/Folder%202/TestDok4.pdfpage=1;
 target=viewer-iframefilename/a

in the PDFClient the PDFViewer should be loaded in the IFrame, which
actually is a blank page that just embeds the PDF-File

...process request-parameters and session-vars...
if(pdfFile!=null) {
output = embed src=\+pdfFile+#page=+pdfPage
+toolbar=0navpanes=0scrollbar=0view=Fit\ width=
\550\ height=\550\;
}

When I call the Viewer with a file 'TestDok1.pdf' which is located in
the 'war' file (main directory of the project), it works well, when a
pdf-file from a location outside the project directory the generated
html looks like it should:

html
head
titlePDFViewer/title
/head
body
embed 
src=document-repository/TestDok1.pdf#page=1toolbar=0navpanes=0scrollbar=0view=Fit
 width=550 height=550
/body
/html

but instead of opening the PDF-File the plugin opens nothing... well at
least it reserves the 550x550 pixels for the presentation but all is white
nothing is displayed

/opt and recursively all contents have rwxrwxrwx... so I would think
the access rights should not be the problem... 

Thx for the quick answer!

Ingo


signature.asc
Description: Dies ist ein digital signierter Nachrichtenteil


Re: Trying to access a directory outside docBase... is it possible ?

2009-12-15 Thread Pid

On 15/12/2009 15:25, Ingo Gambin wrote:

Am Dienstag, den 15.12.2009, 15:01 + schrieb Pid:

o right to my problem, wich I am sure is not too unusual, but I

couldn't really find a solution (via google) so far.

my directory structure looks as follows

/opt/document-repository- mounted nfs-disk of an archiving system

/opt/Tomcat/webapps/myApp.war- my project deployment file

my webapp for now is just a bunch of servlets which, using
java.io.File..., have no trouble to read the archiving systems

directory

structure listing to list all available archived pdf-files. With
servlets and some CSS I managed to build a little directory tree in

the

browser output and linked the pdf-files to get opened (via adobe

reader

plugin) in an iframe

this basically works if the pdf-files I want to open are located in

the

deployment directory.

but what I want to do is to access the pdf-files of the archiving

disk.

it seems tho while the servlet java code {java.io...} CAN, tomcat

CANNOT

access the pdf-files, which are stored there. And my projects

deployment

directory and the archiving systems mount have to be separated, so I

can

not mount the nfs into the deployment directory nor can I put my
application around the nfs-mount-directory

I stumbled over a hint about adding a

Context  docBase=/opt/documents path=/documents/

directive to the web.xml file, but I haven't had any luck with my
experiments so far, but then I realized that this would mean that I

also

have to move my project directory which I can't.

So if there is any possibility to get this done (i am using linux

incase

you haven't guessed already) I would be very glad if anyone could

drop a

few lines to help me out.


What actually happens when you try to access the files?
Does the Tomcat process have sufficient rights to access that
directory?




http://localhost:8080/myApp/PDFClient- entry servlet and main form
http://localhost:8080/myApp/PDFViewer- servlet loaded in IFrame


snip

So what do your app logs say?
If the viewer servlet isn't working where does it throw it's errors?


p


Thx for the quick answer!

Ingo



-
To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org
For additional commands, e-mail: users-h...@tomcat.apache.org



Re: Trying to access a directory outside docBase... is it possible ?

2009-12-15 Thread André Warnier

Ingo Gambin wrote:
...


my directory structure looks as follows

/opt/document-repository  - mounted nfs-disk of an archiving system

/opt/Tomcat/webapps/myApp.war - my project deployment file

my webapp for now is just a bunch of servlets which, using
java.io.File..., have no trouble to read the archiving systems directory
structure listing to list all available archived pdf-files. With
servlets and some CSS I managed to build a little directory tree in the
browser output and linked the pdf-files to get opened (via adobe reader
plugin) in an iframe 


this basically works if the pdf-files I want to open are located in the
deployment directory.

but what I want to do is to access the pdf-files of the archiving disk.
it seems tho while the servlet java code {java.io...} CAN, tomcat CANNOT
access the pdf-files, which are stored there. And my projects deployment
directory and the archiving systems mount have to be separated, so I can
not mount the nfs into the deployment directory nor can I put my
application around the nfs-mount-directory


But maybe you could just create a link, inside your deployment 
directory, to the mount ?


/opt/Tomcat/webapps/myApp/docs -- /opt/document-repository

You would have to make sure that the user-id under which Tomcat runs has 
read access to that directory and to the documents in it.


Otherwise, can you be more precise when you say that tomcat CANNOT 
access the files ? what URL is the client using, and what exactly happens ?


-
To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org
For additional commands, e-mail: users-h...@tomcat.apache.org



Re: Trying to access a directory outside docBase... is it possible ?

2009-12-15 Thread Peter Crowther
2009/12/15 André Warnier a...@ice-sa.com

 But maybe you could just create a link, inside your deployment directory,
 to the mount ?

 /opt/Tomcat/webapps/myApp/docs -- /opt/document-repository

 If you're going to do this, be Very Very Careful.  Tomcat doesn't follow
symbolic links by default, even on UNIX.  This is for a very good reason: if
you do this, Tomcat *will* follow the symlink and delete your PDFs when you
undeploy your webapp.

You probably don't want this to happen.

This is a common enough use case (it comes up about once a month on the
list) that Someone may have coded a quick serve the content from this
directory servlet, probably based on the root webapp.  Chris?  You're
generally the coder with quick hacks already developed...

- Peter


Re: Trying to access a directory outside docBase... is it possible ?

2009-12-15 Thread Pid

On 15/12/2009 16:05, Peter Crowther wrote:

2009/12/15 André Warniera...@ice-sa.com


But maybe you could just create a link, inside your deployment directory,
to the mount ?

/opt/Tomcat/webapps/myApp/docs --  /opt/document-repository

If you're going to do this, be Very Very Careful.  Tomcat doesn't follow

symbolic links by default, even on UNIX.  This is for a very good reason: if
you do this, Tomcat *will* follow the symlink and delete your PDFs when you
undeploy your webapp.

You probably don't want this to happen.

This is a common enough use case (it comes up about once a month on the
list) that Someone may have coded a quick serve the content from this
directory servlet, probably based on the root webapp.  Chris?  You're
generally the coder with quick hacks already developed...


The OP already has a servlet AFAICT.  It's just not working.


p


- Peter




-
To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org
For additional commands, e-mail: users-h...@tomcat.apache.org



Re: Trying to access a directory outside docBase... is it possible ?

2009-12-15 Thread Paolo Santarsiero
2009/12/15 Ingo Gambin igam...@brilliant.de

 Hi,

 I am new to Tomcat and JEE, but a new job means to learn new things.

 So right to my problem, wich I am sure is not too unusual, but I
 couldn't really find a solution (via google) so far.

 my directory structure looks as follows

 /opt/document-repository  - mounted nfs-disk of an archiving system

 /opt/Tomcat/webapps/myApp.war - my project deployment file

 my webapp for now is just a bunch of servlets which, using
 java.io.File..., have no trouble to read the archiving systems directory
 structure listing to list all available archived pdf-files. With
 servlets and some CSS I managed to build a little directory tree in the
 browser output and linked the pdf-files to get opened (via adobe reader
 plugin) in an iframe

 this basically works if the pdf-files I want to open are located in the
 deployment directory.

 but what I want to do is to access the pdf-files of the archiving disk.
 it seems tho while the servlet java code {java.io...} CAN, tomcat CANNOT
 access the pdf-files, which are stored there. And my projects deployment
 directory and the archiving systems mount have to be separated, so I can
 not mount the nfs into the deployment directory nor can I put my
 application around the nfs-mount-directory

 I stumbled over a hint about adding a

  Context  docBase=/opt/documents path=/documents/





 directive to the web.xml file, but I haven't had any luck with my
 experiments so far, but then I realized that this would mean that I also
 have to move my project directory which I can't.

 So if there is any possibility to get this done (i am using linux incase
 you haven't guessed already) I would be very glad if anyone could drop a
 few lines to help me out.

 Thanks in advance!


 Ingo Gambin

 Brilliant Vorsorge GmbH
 Worringer Str. 2-4
 D-40211 Düsseldorf

 Telefon:  +49 (0) 211 / 61793-0
 Mobil:+49 (0) 176 / 44 66 66 42
 eMail:igam...@brilliant.de
 PGP-Fingerprint:  D316 7343 EA4B 82C7 D96D  6917 3BF3 005A DA46 227F



   Context  docBase=/opt/documents path=/documents/

You must create documents.xml in conf/Catalina/localhost/ and put there this
directive, not in web.xml


Re: Trying to access a directory outside docBase... is it possible ?

2009-12-15 Thread André Warnier

Pid wrote:

On 15/12/2009 16:05, Peter Crowther wrote:

2009/12/15 André Warniera...@ice-sa.com

But maybe you could just create a link, inside your deployment 
directory,

to the mount ?

/opt/Tomcat/webapps/myApp/docs --  /opt/document-repository

If you're going to do this, be Very Very Careful.  Tomcat doesn't follow
symbolic links by default, even on UNIX.  This is for a very good 
reason: if
you do this, Tomcat *will* follow the symlink and delete your PDFs 
when you

undeploy your webapp.


Ooops.
(Although I did specify read access for the Tomcat user-id.  If it does 
not have write access to the directory pointed to, it should not be able 
to delete the files, right ?)




You probably don't want this to happen.

This is a common enough use case (it comes up about once a month on the
list) that Someone may have coded a quick serve the content from this
directory servlet, probably based on the root webapp.  Chris?  You're
generally the coder with quick hacks already developed...


The OP already has a servlet AFAICT.  It's just not working.


I think indeed the OP has some kind of servlet, and that one works.
But I understood that he wanted Tomcat to serve these documents 
directly, as files, not going through a servlet.

Maybe I got that wrong.
OP ?


-
To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org
For additional commands, e-mail: users-h...@tomcat.apache.org



RE: Trying to access a directory outside docBase... is it possible ?

2009-12-15 Thread Caldarale, Charles R
 From: peter.crowth...@googlemail.com
 [mailto:peter.crowth...@googlemail.com] On Behalf Of Peter Crowther
 Subject: Re: Trying to access a directory outside docBase... is it
 possible ?
 
 This is a common enough use case (it comes up about once a month on the
 list) that Someone may have coded a quick serve the content from this
 directory servlet, probably based on the root webapp.

A special servlet is not required - Tomcat's default servlet will do the job.  
Paolo already gave the correct answer, which is to set up a Context element 
for a dummy webapp:

  Context  docBase=/opt/documents path=/documents/

 You must create documents.xml in conf/Catalina/localhost/ and put there this
 directive, not in web.xml

Although the path attribute must not be used - just the docBase.

 - Chuck


THIS COMMUNICATION MAY CONTAIN CONFIDENTIAL AND/OR OTHERWISE PROPRIETARY 
MATERIAL and is thus for use only by the intended recipient. If you received 
this in error, please contact the sender and delete the e-mail and its 
attachments from all computers.


-
To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org
For additional commands, e-mail: users-h...@tomcat.apache.org



Re: Trying to access a directory outside docBase... is it possible ?

2009-12-15 Thread Christopher Schultz
-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1

Peter,

On 12/15/2009 11:05 AM, Peter Crowther wrote:
 If you're going to do this, be Very Very Careful.  Tomcat doesn't follow
 symbolic links by default, even on UNIX.  This is for a very good reason: if
 you do this, Tomcat *will* follow the symlink and delete your PDFs when you
 undeploy your webapp.
 
 You probably don't want this to happen.

+1 :)

 This is a common enough use case (it comes up about once a month on the
 list) that Someone may have coded a quick serve the content from this
 directory servlet, probably based on the root webapp.  Chris?  You're
 generally the coder with quick hacks already developed...

Uh, file-serving code is pretty simple: set the Content-Type and
Content-Length headers, open the file, deliver the bytes.

It's so popular that it's already been written and even ships with
Tomcat: it's called the DefaultServlet :)

Seriously, though, Ingo was very close to a working solution:

 I stumbled over a hint about adding a 
 
   Context  docBase=/opt/documents path=/documents/
 
 directive to the web.xml file

Ohh! So close! That should be added to conf/server.xml (but not really,
since that's no longer recommended). Let's do it the right way:

Put this into conf/Catalina/localhost/document-repository.xml:

   Context docBase=/opt/document-repository path=/documents /

I think you might have to restart Tomcat for it to pick up that config
file, but it will create a new webapp context that serves files directly
from that location. Your URLs will no longer look like this:

http://localhost:8080/myApp/PDFViewer?file=document-repository/Folder%202/TestDok4.pdfpage=1

Instead, they can look just like this:

/documents/Folder%202/TestDok4.pdfpage=1

You can even get rid of your PDFViewer servlet, because it's probably
just serving bytes and not doing anything particularly exciting.

- -chris
-BEGIN PGP SIGNATURE-
Version: GnuPG v1.4.10 (MingW32)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iEYEARECAAYFAksn2SsACgkQ9CaO5/Lv0PDlQACglU4lGn9398YVUBpjMGtbJP2X
beoAn1zI4YyBJe9sr2MYZOSdlyCqXi3o
=RPfr
-END PGP SIGNATURE-

-
To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org
For additional commands, e-mail: users-h...@tomcat.apache.org