You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by Joel Boyd <Jo...@veritas.com> on 2001/05/26 00:13:14 UTC

Servlet, JSPs and images...

I am using Tomcat to run a Servlet, and the Servlet forwards requests, via a
RequestDispatcher, to my JSP pages.
Tomcat is finding the JSP pages, but not the images referenced in them.

My JSP pages are in webapps/myapp and my images are in webapps/myapp/images.
I reference the images using "images/myimage.gif", and it worked before when
I was directly serving up the JSP pages.  Now Tomcat complains that it
cannot find the images:

	/myapp/servlet/images/myimage.gif  returns null

I tried creating a webapps/myapp/servlet/images directory and put all my
images there, but that still did not work.

Does anyone know what is going on here?

Thanks.

Joel Boyd


Re: Servlet, JSPs and images...

Posted by anil <an...@awcoldstream.com>.
This might woryour webapp

webapp---WEB-INF/classes/..
            |---images/foo.gif
            |---jsp/bar.jsp



String reqContext = request.getContextPath();
String image =reqContext+"/images/foo.gif";


anil


Joel Boyd wrote:

> I am using Tomcat to run a Servlet, and the Servlet forwards requests, via a
> RequestDispatcher, to my JSP pages.
> Tomcat is finding the JSP pages, but not the images referenced in them.
>
> My JSP pages are in webapps/myapp and my images are in webapps/myapp/images.
> I reference the images using "images/myimage.gif", and it worked before when
> I was directly serving up the JSP pages.  Now Tomcat complains that it
> cannot find the images:
>
>         /myapp/servlet/images/myimage.gif  returns null
>
> I tried creating a webapps/myapp/servlet/images directory and put all my
> images there, but that still did not work.
>
> Does anyone know what is going on here?
>
> Thanks.
>
> Joel Boyd