Hehe,

this I learned only a few days ago. I hope you didn't loose valuable
information. 

But yes, this is the expected behaviour. 

In order to solve the problem you just have to add 'fake' docBases ...
see below in the answers I got from Chris.

Although i have to add, that adding the <Context...> directive to 
        conf/Catalina/localhost/<name>.xml
did not work for me on Tomcat 5.5. 

Putting it into server.xml on the other hand worked perfectly.

Best regards,

Ingo

Am Freitag, den 18.12.2009, 02:01 -0800 schrieb Vishwa. K:
> Tomcat 5.5.17
> Solaris 5.10
> 
> Our Web Application is required to display hyperlinks to external files that 
> reside outside the web application based on certain business rules. The users 
> could then download these large PDF files.
> 
> We went ahead with the idea of symbolic links supported by Tomcat.
> 
> <Context path="/powerApp" allowLinking="true"/>
> 
> We deployed the application and created a symbolic link under the web 
> application directory to point to another external directory on the same 
> server. All the hyperlinks use the symbolic link.
> 
> The Application worked fine. When we undeploy the application, Tomcat seems 
> to be deleting the war file, the exploded directory and also all 
> the external files that are present in the directory pointed to by the 
> symbolic link!
> 
> I was expecting tomcat to delete only the war file, the exploded directory 
> including the symbolic link, but not the external PDF files during an 
> undeployment!
> 
> I googled on the net and found that this behaviour has been observed on both 
> Tomcat 5.x and Tomcat 6.x but no proper explanation to this issue.
> 
> I was wondering if this is the expected behaviour of Tomcat in this scenario 
> or is it a bug?
> 
> 
> 
> 
>       
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org
> For additional commands, e-mail: users-h...@tomcat.apache.org
> 

--- Begin Message ---
-----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.pdf&page=1

Instead, they can look just like this:

/documents/Folder%202/TestDok4.pdf&page=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


--- End Message ---

Attachment: signature.asc
Description: Dies ist ein digital signierter Nachrichtenteil

Reply via email to