tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Ed Gomolka <>
Subject Re: How to get around a tricky situation.
Date Wed, 04 Apr 2001 10:22:54 GMT
On Tuesday 03 April 2001 09:23, Alex Colic wrote:
> Hi,
> I need some advice on how I might fix a problem with one of our web apps.
> We farmed out an app that works ok except that the web pages which are
> created by servlets are looking for images in the tomcat root images
> directory. This presents a problem in that if I create a war of our app I
> also have to distribute and copy the images over to the root images
> directory.
> Can I set up my web.xml file so that when a web page looks for an image in
> the /images directory it actually pulls them out of my myWebApp/images
> directory.
You best bet is to change your source code to pick up the
path dynamically.
You can use something like the following to
determine the image path relative to the base of your context:
    public void init(ServletConfig config) throws ServletException
        servletContext = config.getServletContext();
        String contextPath = servletContext.getRealPath("/");
        String imagesDirectory = contextPath + "images";


Ed Gomolka

View raw message