tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Kiran Badi <ki...@poonam.org>
Subject Re: Where do I store Images in tomcat structure so that I can retrive it properly in all browsers
Date Sun, 23 Sep 2012 04:10:31 GMT
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.

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

    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.

    There's really only one rule for servlet programming:

    Don't use class-level data that changes.

    There are other considerations, of course, but a servlet is not a
    sacred beast. There's only one way to learn how to do it properly:
    fall on your face a few times.

Yes I understand this somewhat and thats the reason probably I am 
somewhat hesitating to reuse some of classes and thats increasing size 
of my code and probably duplicating my code.But again there are some 
good things, I can extend those classes in future and can bring down 
those modules if required without impacting any thing or making an 
changes to existing code.This is only plus point I can see 
now.Everything now is independent of each other. Finally at least I am 
enjoying doing something good rather than finding silly bugs and chasing 
developers for fixing those.

I will upgrade to 7.30 shortly if it saves me some memory.

Thanks Chris and Konstantin.Appreciate your guidance.



Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message