I am using the RequestDispatcher's forward() method to redirect to a JSP. The problem is that the jsp's url is now relative to the servlet's url and all my url's in the jsp such as <img src="pic.gif"> will be corrupt. How do I solve this problem?
Dmitry Ivlev You can use absolute urls like:
<BODY> <% String base = request.getContextPath(); %> <IMG src="<%=base%>/img/pic.gif"> </BODY>or write out a BASE tag like:
<% String base = request.getContextPath(); %> <HEAD> <BASE HREF="<%=base%>"> </HEAD> <BODY> <IMG src="img/pic.gif"> </BODY>That should take care of the problem.