Andre,

Thanks.  I know serving images from the classes directory is not the best
way to do stuff.  But from a maintenance/source control stand point it sure
would make things a lot easier if I didn't have to pick and choose what
directories to move when deploying on the users machines.  Because the tool
app deploys the web apps that it builds as classes under it's own classes
directory, I have to move all of my custom scripts and graphics to another
location in order to use them.  As I said it would make my life much easier
if everything was in one spot.  That way I could package everything easier
and maintain with subversion easier.  This is a windows box so I can't just
put links in the other area.  I actually have to move or copy the pieces.
Having multiple copies of the same objects is not a fix because they have to
be kept up to date.

I knew when I posted the first request that it was strange.  But sometimes
we have to take that square peg and hammer it into the round whole.  So if
anyone has any ideas (I will take a look at your rewriting url stuff.
Thanks!) how this can be done then I am all ears.  If you just want to slam
me for doing something different then don't bother.  

Thanks,
Susan    

-----Original Message-----
From: André Warnier [mailto:a...@ice-sa.com] 
Sent: Wednesday, June 17, 2009 4:34 PM
To: Tomcat Users List
Subject: Re: Serving images from classes directory

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:funk...@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-unsubscr...@tomcat.apache.org
> For additional commands, e-mail: users-h...@tomcat.apache.org
> 
> 
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org
> For additional commands, e-mail: users-h...@tomcat.apache.org
> 
> 


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




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

Reply via email to