If you're in JSP or Facelets, it is way better to use HttpServletRequest#getContextPath
:
<img src="${request.contextPath}/images/java_logo.gif" />
If you happen to use JSTL:
<img src="<c:url value="images/java_logo.gif" />" />
In this way, you avoid using relative paths and/or guessing what would be your current web application path (this is in case you change the name to display the app or something similar). For example, if you happen to have this structure:
- WebContent
- images
+ java_logo.gif
- jsp
+ Header.jsp
- anotherFolder
+ Another.jsp
If you want to add java_logo.gif in Another.jsp, you just need to do this:
<img src="${request.contextPath}/images/java_logo.gif" />
Unlike the relative path:
<img src="../../images/java_logo.gif" />