The filter (below) can be made smarter to perform smarter checks - so "regular images" could be excluded.

-Tim

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

Reply via email to