tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Christopher Schultz <ch...@christopherschultz.net>
Subject Re: Where do I store Images in tomcat structure so that I can retrive it properly in all browsers
Date Mon, 24 Sep 2012 19:07:26 GMT
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Kiran,

On 9/23/12 12:10 AM, Kiran Badi wrote:
> On 9/17/2012 10:20 PM, Christopher Schultz wrote:
>> If you instead implemented your own "aliases" feature using a
>> servlet, you could do it in a smarter way because you understand
>> your own URL space: you might always know that /images/X will
>> translate directly into /file/place/on/the/disk/X and you don't
>> have to do a prefix match. You could do something like this:
>> 
>> // configured once Map<String,File> dirMapping = ...; String
>> imageURIPrefix = "/images/";
>> 
>> // For each request: String uri = request.getRequestURI(); String
>> imageDirStr = uri.substring(0, uri.indexOf('/')); File dir =
>> dirMapping.get(imageDirStr);
>> 
>> Now you know where your file should be, and there wasn't any
>> linear lookup: it was all done using hashes.
> 
> Ah, I can implement it, if my understanding is correct, what you
> are suggesting here is that grab the incoming url, check if they
> are making a request to Images, if yes then point the url to the
> appropriate directory of images for serving.I can do this if it
> gives me good performance.
> 
> I was under impression that Tomcat checks for the alias only once
> during it start up phase and somehow maintains the list of it in
> memory and will do automatic match without scanning each alias.My
> bad.

Tomcat must perform the "scan" for every request.

> Alias as per my understanding is the one of the places where
> Tomcat looks for resources to serve for the requests.

Correct. It's just that the specification is such that it can't be
that smart about finding resources without taking a snapshot of the
whole view of the filesystem and caching it in memory (which itself
isn't very smart).

>> Probably not: the suggestion was to use, say, ${imagePrefix} in
>> your context's aliases setup to simplify the re-location of your
>> image root on disk.
> 
> I did not get this probably one of the reasons could be I am still 
> struggling to come to speed.I might need some more days to think as
> what this means in terms of implementation.

Uh, okay.

- -chris
-----BEGIN PGP SIGNATURE-----
Version: GnuPG/MacGPG2 v2.0.17 (Darwin)
Comment: GPGTools - http://gpgtools.org
Comment: Using GnuPG with Mozilla - http://www.enigmail.net/

iEYEARECAAYFAlBgr20ACgkQ9CaO5/Lv0PDsvQCeMKpibaNMc88y0reTbgTGuGcV
RtEAoMGSc0zZgt+Br6ZPFqbFewPcUSA0
=uLtc
-----END PGP SIGNATURE-----

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


Mime
View raw message