tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Milbaugh, Theodore K (Ted)" <ted.milba...@nationwide.com>
Subject RE: Re: Making PreResources configuration recurse directories
Date Thu, 06 Jun 2019 12:50:50 GMT
> -----Original Message-----
> From: Christopher Schultz <chris@christopherschultz.net>
> Sent: Wednesday, June 5, 2019 4:37 PM
> To: users@tomcat.apache.org
> Subject: [EXTERNAL] Re: Making PreResources configuration recurse directories
> 
> Nationwide Information Security Warning: This is an external email. Do not click
> on links or open attachments unless you trust the sender.
> ------------------------------------------------------------------------------
> 
> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA256
> 
> Theodore,
> 
> On 6/5/19 15:16, Milbaugh, Theodore K (Ted) wrote:
> > I am using Tomcat version 9.0.12
> >
> > I have a PreResources tag in my context.xml like this:
> >
> > <Resources
> > className="org.apache.catalina.webresources.StandardRoot">
> > <PreResources
> > className="org.apache.catalina.webresources.DirResourceSet"
> > base="C:\\good_files\\goodies_in_here" internalPath="/"
> > webAppMount="/" /> </Resources>
> >
> > This works great, in that if I access a JSP like this:
> >
> > http://localhost:8080/candy/chocolate.jsp
> >
> > I am able to access the JSP with no issues. However, there are
> > subdirectories in C:\good_files\goodies_in_here. If I try to access a
> > JSP in a subdirectory:
> >
> > http://localhost:8080/candy/crunchy/peanut_brittle.jsp
> >
> > I get a 404, even though the file
> > C:\good_files\goodies_in_here\crunchy\ peanut_brittle.jsp exists.
> > Do I have to create a PreResources tag for each subdirectory in my
> > tree?
> 
> What you are doing is expected to work. It doesn't map a single directory and
> its (non-directory) contents into a single directory. It grafts entire trees into
> the URL space.
> 
> It may be a copy/paste error, but I see a space between your "crunchy/" and
> "peanut_brittle.jsp" strings. It should not matter, but if you replace "\\" in your
> configuration with "/", does that improve things?
> 
> I would caution you about the use of <PreResources>. If there is for example a
> WEB-INF/web.xml file in there or WEB-INF/classes, then those will be loaded
> before the web application's "normal" files are loaded, which may be surprising.
> 
> - -chris

Chris:
I might have been seeing a permissions error. I copied all of the resource files to a local
directory, and everything is working as expected now.

Thanks for your advice, I changed my configuration to a PostResources tag, and used forward
slashes for my directory specification.

Ted Milbaugh
ted.milbaugh@nationwide.com

Mime
View raw message