Within the JSP make all links to other resources relative to the URL of the controller servlet.
IE: If the url-pattern of your controller is /SomeServlet and you use the following url to call it: http://localhost:8080/SomeServlet then the links and references in someJsp need to be relative to the root of your application. <image src="images/some/image"> The browser doesn't know that the JSP page was nested under the "jsp" directory.
The other approach is to always make them relative to the root of your context: [ May 28, 2005: Message edited by: Ben Souther ]
Ben, I know that if I modifiy all the JSP files I can get it working. But what I want is that after Dispatching(or before or some how) I can tell the tomcat where to resolve relative paths against. Because I have .js files being called in my jsp pages. These .js files also refere resources like images and css files. I cant use jsp stuff in .js files and dont want to change the paths in js files.
I can tell the tomcat where to resolve relative paths against.
It isn't tomcat that you need to tell. It's the browser. When you do a server side forward, the browser has no idea what file you're serving up to it. It only knows about the URL that it used to hit the controller.
I keep it simple by always creating url-patterns that are not nested: <url-pattern>/SomePage</url-pattern> As opposed to: <url-pattern>/someDirectory/SomePage</url-pattern>
That way, all of my links can be relative to the root of the app: src="images/myImage".
The second approach that I mentioned is probably the most robust because it won't matter what the url-pattern of the controller is. Request.getContextPath will aways get the user to the root of the app. I can then make all the paths relative to that.
Try right clicking on one of your broken image links and viewing it's properties. This will show you where the browser is looking for the image.