tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From André Warnier ...@ice-sa.com>
Subject Re: Serving images from classes directory
Date Wed, 17 Jun 2009 20:34:25 GMT
Susan,
have a look at this :
http://tuckey.org/urlrewrite/

This is a "servlet filter", which kind of "wraps" your webapp, 
intercepting all calls before they reach your webapp.
On the way, it allows you to modify the request URL (for instance), to 
for example to redirect the call to some simple servlet which would just 
return said image.
Or maybe - my knowledge is too limited to really tell - arrange for 
these calls to be served by Tomcat's default webapp, which serves static 
items.

Note that I am not in all this taking a stance on whether what you want 
to do is fundamentally a good idea, which from the previous expert 
testimonies here, it seems it is not.

Also, the reason that said experts object so strenuously to what you 
want to do, is not that they just personally don't like it for some 
reason of elegance or so.  Their main objection probably has to do with 
the security of your website.  Mixing code (which you do not want to 
disclose to just about anyone) with static objects (which you want to 
disclose of course) is probably the best way to introduce huge holes in 
whatever security scheme your site would otherwise have.
So the experts are telling you "don't do that", because in their expert 
and considerate opinion, they don't feel that they should help you do by 
yourself something that will definitely put your site at risk.


Susan G. Conger wrote:
> Thanks Tim.  I don't have control during build because that is done by the
> third party tool.  I am not going to mention their name.  I was hoping that
> this would be easy.  You know a servlet mapping in the web.xml file that
> would allow me to just map the directory/file type and I could just put that
> in my html.  Since I can't use jsp everywhere I need the images.  Again I am
> tied into their system and they have stuff in html files that they create.
> I edit the html template files they have to add my images and javascript.
> I use their environment to create/edit/build the web application. Underneath
> I have tied in netBeans the best I can so I can debug their stuff.  But that
> has issues too.  
> 
> Thanks,
> Susan
> 
> -----Original Message-----
> From: Tim Funk [mailto:funkman@apache.org] 
> Sent: Wednesday, June 17, 2009 1:07 PM
> To: Tomcat Users List
> Subject: Re: Serving images from classes directory
> 
> If the images are physical images in the classes directory - you have a 
> few options.
> 
> 1) At build time - move (or copy) the files from the classes directory 
> to somewhere more sane that the default servlet can access
> 2) Write a filter the detects these images that live in the classes dir, 
> and then forwards to the images. (You need to be careful with this one)
> 
> For # 2 - it would look something like this:
> doFilter(...) {
>    String p = request.getServletPath();
>    if (p.matches("/magic_prefix/[\\w]+\\.gif$")) {
>      String np = request.getServletPath().replaceFirst(".+/", "");
>      request.getRequestDispatcher("/WEB-INF/class/more/cowbell/" + np)
>             .forward(request, response);
>    } else {
>      chain.doFilter(...);
>    }
> }
> 
> 
> -Tim
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
> For additional commands, e-mail: users-help@tomcat.apache.org
> 
> 
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
> For additional commands, e-mail: users-help@tomcat.apache.org
> 
> 


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


Mime
View raw message