I have a servlet "TestServlet" doing the following: RequestDispatcher rd; ServletContext sc = this.getServletContext(); rd = sc.getRequestDispatcher("/test.jsp"); rd.forward(req, res); in test.jsp it has the following line <a href="/myapp/servlet/TestServlet?param=a" ><img src="images/pic.gif" alt="" ></a> The servlet is put in "myapp/WEB-INF/classes/" folder and the jsp is in "myapp" folder. Then I open a browser and go to "http://localhost ort/myapp/servlet/TestServlet?param=..", what I find is the picture doesn't show up. However, when I open "http://localhost ort/myapp/test.jsp" the picture shows there. So somehow the problem is from "forward". But I don't see anything wrong here. Please help !
It doesn't really have anything to do with the forward, but with the URI that the browser is trying to use as the base reference. Another option is to use the <base> tag to establish an artificial relative base.
subject: img src="..." has problem when using "forward".