Hello Tim

Saw your posting on the tomcat user's list.
I have a question about your response:

So how do you access the static resources, i.e.,
images, from the other two web apps?

This is what I tried and it does not work:

I created a separate webapp context with images,
and placed into tomcat/conf/Catalina/localhost
a <Context...> element that looks like this:

   <Context path="/img"
            docBase="img"
            debug="0"
            reloadable="true"
            allowLinking="true" />
   </Context>

and in webapps/img I

   ln -s /usr/scratch/images images

to create the symlink.  So far, so good
Then, for the web app which needed the images,
I created this <Context...> element:

   <Context path="/getimg"
            docBase="getimg"
            debug="0"
            reloadable="true"
            crossContext="true">
   </Context>

Then from one of the servlets in getimg, I tried to

    try {
RequestDispatcher dispatcher = getServletContext().getContext("/img").getRequestDispatcher("/images"+request.getPathInfo());
        dispatcher.include(request, response);
     } catch(Exception ex) {
        ex.printStackTrace();
     }

and to invoke as getimg/ImageServlet/subPath...
but nothing happened, and in fact, the

    getServletContext().getContext("/img") returned null.

Note that the thusly constructed path to the image is
in fact correct.  This was not an issue of Not Found.


Thanks

Maurice Yarrow








> I typically create a 3rd webapp with those shared images and other
> similar assets.
>
> Otherwise - you can import those shared assets into your webapp at
> build time by placing all the shared assets into their own version
> control repository.
>
> -Tim


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to