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:

<% String base = request.getContextPath(); %>
<IMG src="<%=base%>/img/pic.gif">
or write out a BASE tag like:
<% String base = request.getContextPath(); %>
<BASE HREF="<%=base%>">

<IMG src="img/pic.gif">
That should take care of the problem.
0 Comments  (click to add your comment)
Comment and Contribute






(Maximum characters: 1200). You have 1200 characters left.