Return-Path: Delivered-To: apmail-tomcat-users-archive@www.apache.org Received: (qmail 69052 invoked from network); 15 Dec 2009 18:45:29 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.3) by minotaur.apache.org with SMTP; 15 Dec 2009 18:45:29 -0000 Received: (qmail 98035 invoked by uid 500); 15 Dec 2009 18:45:25 -0000 Delivered-To: apmail-tomcat-users-archive@tomcat.apache.org Received: (qmail 97966 invoked by uid 500); 15 Dec 2009 18:45:24 -0000 Mailing-List: contact users-help@tomcat.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: "Tomcat Users List" Delivered-To: mailing list users@tomcat.apache.org Received: (qmail 97955 invoked by uid 99); 15 Dec 2009 18:45:24 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 15 Dec 2009 18:45:24 +0000 X-ASF-Spam-Status: No, hits=-2.6 required=5.0 tests=AWL,BAYES_00 X-Spam-Check-By: apache.org Received-SPF: neutral (athena.apache.org: local policy) Received: from [76.96.59.243] (HELO QMTA13.westchester.pa.mail.comcast.net) (76.96.59.243) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 15 Dec 2009 18:45:22 +0000 Received: from OMTA05.westchester.pa.mail.comcast.net ([76.96.62.43]) by QMTA13.westchester.pa.mail.comcast.net with comcast id HQe21d0040vyq2s5DWl2aQ; Tue, 15 Dec 2009 18:45:02 +0000 Received: from [192.168.1.200] ([69.143.128.194]) by OMTA05.westchester.pa.mail.comcast.net with comcast id HWl11d00H4BnRt93RWl1bh; Tue, 15 Dec 2009 18:45:02 +0000 Message-ID: <4B27D92B.302@christopherschultz.net> Date: Tue, 15 Dec 2009 13:44:59 -0500 From: Christopher Schultz User-Agent: Mozilla/5.0 (Windows; U; Windows NT 6.0; en-US; rv:1.9.1.5) Gecko/20091130 Thunderbird/3.0 MIME-Version: 1.0 To: Tomcat Users List Subject: Re: Trying to access a directory outside docBase... is it possible ? References: <1260884816.2385.42.camel@igambin-desktop> <4B27ADB2.5020803@ice-sa.com> In-Reply-To: X-Enigmail-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit -----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 > > > > 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: 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-unsubscribe@tomcat.apache.org For additional commands, e-mail: users-help@tomcat.apache.org