title: image not displayed in jsp with spring
body: <p>I am new to spring with jsp i am basically trying to display an image in my jsp</p>
  
  <pre class="lang-html prettyprint-override"><code>&lt;html&gt;
      &lt;head&gt;
          &lt;meta http-equiv="Content-Type" content="text/html; charset=windows-1252"&gt;
          &lt;title&gt;JSP-Page&lt;/title&gt;
      &lt;/head&gt;
      &lt;body&gt;
          &lt;img src="images/top.jpg"&gt;
      &lt;/body&gt;
  &lt;/html&gt; 
  </code></pre>
  
  <p>Spring-servlet xml :</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
  &lt;beans xmlns="http://www.springframework.org/schema/beans"
         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:p="http://www.springframework.org/schema/p"
         xmlns:context="http://www.springframework.org/schema/context"
         xmlns:mvc="http://www.springframework.org/schema/mvc"
         xsi:schemaLocation="
      http://www.springframework.org/schema/beans
      http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
      http://www.springframework.org/schema/context
      http://www.springframework.org/schema/context/spring-context-3.0.xsd
      http://www.springframework.org/schema/mvc
      http://www.springframework.org/schema/mvc/spring-mvc-3.0.xsd"&gt;
  
      &lt;!-- Enable annotation driven controllers, validation etc... --&gt;
      &lt;mvc:annotation-driven /&gt;
   &lt;mvc:resources location="/images/" mapping="/images/**"/&gt;
  
      &lt;!-- Application controllers package --&gt;
      &lt;context:component-scan base-package="net.ignou.onlinetest.controller" /&gt;
  
      &lt;bean id="viewoseesolver"
                class="org.springframework.web.servlet.view.InternalResourceViewResolver"&gt;
          &lt;property name="prefix"&gt;
              &lt;value&gt;/WEB-INF/views/&lt;/value&gt;
          &lt;/property&gt;
          &lt;property name="suffix"&gt;
              &lt;value&gt;.jsp&lt;/value&gt;
          &lt;/property&gt;
      &lt;/bean&gt;
  
      &lt;bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource"
                destroy-method="close"&gt;
          &lt;property name="driverClassName" value="com.mysql.jdbc.Driver" /&gt;
          &lt;property name="url"
                            value="jdbc:mysql://localhost:3306/online_test" /&gt;
          &lt;property name="username" value="root" /&gt;
          &lt;property name="password" value="root" /&gt;
      &lt;/bean&gt;
  
      &lt;bean id="sessionFactory"
                class="org.springframework.orm.hibernate3.annotation.AnnotationSessionFactoryBean"&gt;
          &lt;property name="dataSource" ref="dataSource" /&gt;
          &lt;property name="annotatedClasses"&gt;
              &lt;list&gt;
                  &lt;value&gt;net.ignou.onlinetest.domain.Question&lt;/value&gt;
                  &lt;value&gt;net.ignou.onlinetest.domain.Student&lt;/value&gt;
                  &lt;value&gt;net.ignou.onlinetest.domain.Answer&lt;/value&gt;
              &lt;/list&gt;
          &lt;/property&gt;
          &lt;property name="hibernateProperties"&gt;
              &lt;props&gt;
                  &lt;prop key="hibernate.dialect"&gt;org.hibernate.dialect.MySQL5InnoDBDialect&lt;/prop&gt;
                  &lt;prop key="hibernate.show_sql"&gt;true&lt;/prop&gt;
                  &lt;prop key="hibernate.hbm2ddl.auto"&gt;none&lt;/prop&gt;
              &lt;/props&gt;
          &lt;/property&gt;
      &lt;/bean&gt;
  
      &lt;bean id="multipartResolver"
                class="org.springframework.web.multipart.commons.CommonsMultipartResolver"&gt;
      &lt;/bean&gt;
  
      &lt;bean id="questionDao" class="net.ignou.onlinetest.dao.daoImpl.QuestionDaoImpl"&gt;
          &lt;property name="sessionFactory" ref="sessionFactory"/&gt;
      &lt;/bean&gt;
      &lt;bean id="loginDao" class="net.ignou.onlinetest.dao.daoImpl.LoginDaoImpl"&gt;
          &lt;property name="sessionFactory" ref="sessionFactory"/&gt;
      &lt;/bean&gt;
  
      &lt;bean id="answerDao" class="net.ignou.onlinetest.dao.daoImpl.AnswerDaoImpl"&gt;
          &lt;property name="sessionFactory" ref="sessionFactory"/&gt;
      &lt;/bean&gt;
  
      &lt;bean id="service" class="net.ignou.onlinetest.service.serviceImpl.ServiceImpl"&gt;
          &lt;property name="questionDao" ref="questionDao"/&gt;
      &lt;/bean&gt;
  
  &lt;/beans&gt;
  </code></pre>
  
  <p>My web.xml</p>
  
  <pre><code>&lt;web-app version="2.4" xmlns="http://java.sun.com/xml/ns/j2ee"
      xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
      xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd"&gt;
  
      &lt;display-name&gt;Person Detail&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;/servlet-mapping&gt;
  &lt;welcome-file-list&gt;
          &lt;welcome-file&gt;index.jsp&lt;/welcome-file&gt;
      &lt;/welcome-file-list&gt;
     &lt;/web-app&gt;
  </code></pre>
  
  <p>I am using maven.My image file is located at</p>
  
  <p>online-test\src\main\webapp\images
  and my jsp page is in </p>
  
  <p>online-test\src\main\webapp\web-inf\views</p>
  
  <p>I also tried replacing the src as  <code>&lt;img src="../../images/top.jpg"&gt;</code> but it didnt work i also tried moving my jsp  and image to webapp folder directly also but no use. Is there anything im doing wrong how exactly does spring handle img requests?</p>