title: Image not displayed on JSP page
body: <p>I have a simple JSP page that has one image that is part of the JSP page but that image is not displayed when I view the webpage.  I can view the webpage but it does not include the image.  </p>
  
  <p>I have my img folder located in several places because I am trying to fix this problem. Inside the img folder is where I have img.jpg image that should be displayed inside JSP page.</p>
  
  <p><code>war/img/img.jpg</code></p>
  
  <p><code>war/WEB-INF/jsp/img/img.jpg</code></p>
  
  <p>I am also not able to view img.jpg directly from my web server.  For example: <code>//localhost:8080/register/img/img.jpg</code>  I get HTTP Status 404 - </p>
  
  <p>Here is my web.xml file</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
  &lt;web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" id="WebApp_ID" version="2.5"&gt;
      &lt;display-name&gt;SpringExampleSanjeev&lt;/display-name&gt;
      &lt;servlet&gt;
          &lt;servlet-name&gt;dispatcher&lt;/servlet-name&gt;
          &lt;servlet-class&gt;org.springframework.web.servlet.DispatcherServlet&lt;/servlet-class&gt;
          &lt;load-on-startup&gt;1&lt;/load-on-startup&gt;
      &lt;/servlet&gt;
  
      &lt;servlet-mapping&gt;
          &lt;servlet-name&gt;dispatcher&lt;/servlet-name&gt;
          &lt;url-pattern&gt;/&lt;/url-pattern&gt;
          &lt;url-pattern&gt;/img/*&lt;/url-pattern&gt;
      &lt;/servlet-mapping&gt;
  
      &lt;!-- Enable these types of content(files) to be viewed from webpage  --&gt;
      &lt;servlet-mapping&gt;
          &lt;servlet-name&gt;default&lt;/servlet-name&gt;
          &lt;url-pattern&gt;*.css&lt;/url-pattern&gt;
      &lt;/servlet-mapping&gt;
  
      &lt;servlet-mapping&gt;
          &lt;servlet-name&gt;default&lt;/servlet-name&gt;
          &lt;url-pattern&gt;*.js&lt;/url-pattern&gt;
      &lt;/servlet-mapping&gt;
  
      &lt;servlet-mapping&gt;
          &lt;servlet-name&gt;default&lt;/servlet-name&gt;
          &lt;url-pattern&gt;*.gif&lt;/url-pattern&gt;
      &lt;/servlet-mapping&gt;
  
      &lt;servlet-mapping&gt;
          &lt;servlet-name&gt;dispatcher&lt;/servlet-name&gt;
          &lt;url-pattern&gt;*.jpg&lt;/url-pattern&gt;
      &lt;/servlet-mapping&gt;
  
      &lt;servlet-mapping&gt;
          &lt;servlet-name&gt;default&lt;/servlet-name&gt;
          &lt;url-pattern&gt;*.png&lt;/url-pattern&gt;
      &lt;/servlet-mapping&gt;
  &lt;/web-app&gt;
  </code></pre>
  
  <p>Here is snippet of my JSP page</p>
  
  <pre><code>   &lt;img border="0" src="/img/img.jpg" alt="header banner" width="304" height="228"&gt;
     &lt;img src="&lt;c:url value="/img/img.jpg" /&gt;" alt="TestDisplay"/&gt;
     &lt;img src="&lt;c:url value='/img/img.jpg'/&gt;" /&gt;
     &lt;img alt="OS usage" src="/img/img.jpg"&gt;
     &lt;img border="0" src="/WEB-INF/jsp/img/img.jpg" alt="header banner" width="304" height="228"&gt;
     &lt;img border="0" src="/register/WEB-INF/jsp/img/img.jpg" alt="header banner" width="304" height="228"&gt;
     &lt;img src="img.jpg"&gt;
     &lt;img src="/img/img.jpg"&gt;
     &lt;img src="/jsp/img/img.jpg"&gt;
     &lt;img src="/register/jsp/img/img.jpg"&gt;
     &lt;img src="/WEB-INF/jsp/img/img.jpg"&gt;
     &lt;img src="/register/WEB-INF/jsp/img/img.jpg"&gt;
  </code></pre>
  
  <p>I am not sure what I am doing wrong.  Putting an simple image on JSP page should not be this hard. </p>