title: couldnt transfer data from spring controller to jsp
body: <p>i am stuck with this one spring example.I am getting data from user via jsp page and save method from the controller is evoked and the data is stored in the database through hibernateTemplate.save() method.I am able to achieve until this but when i try to display the data by passing the data to jsp i get http 404 error.My controller class is as follows</p>
  
  <p>CController.java</p>
  
  <pre><code>import project4.UserDAO1;
  import project4.User1;
  import java.util.Map;
  import javax.servlet.http.HttpServletRequest;
  import javax.servlet.http.HttpServletResponse;
  import org.springframework.stereotype.Controller;
  import org.springframework.transaction.annotation.Transactional;
  import org.springframework.ui.ModelMap;
  import org.springframework.web.bind.annotation.RequestMapping;
  import org.springframework.web.bind.annotation.RequestMethod;
  import org.springframework.web.servlet.ModelAndView;
  import org.springframework.web.servlet.mvc.multiaction.MultiActionController;
  import org.springframework.web.bind.annotation.ModelAttribute;
  import org.springframework.validation.BindingResult;
  import org.springframework.beans.factory.annotation.Autowired;
  import org.springframework.beans.factory.annotation.Qualifier;
  
  
  @Controller
  
  
  public class CController{
  
      private UserDAO1 userDAO;
      @Autowired
      @Qualifier("myUserDAO")
      private UserDAOImpl1 myUserDAO;
  
      public void setUserDAO(UserDAO1 userDAO) {
          this.userDAO = userDAO;
      }
  
      @RequestMapping(value = "/frm4/add", method = RequestMethod.POST)
     public ModelAndView add( @ModelAttribute("add") User1 user,HttpServletRequest 
           request,HttpServletResponse response) throws Exception {
           System.out.println("hai");
  
      userDAO.saveUser(user);
      System.out.println("hai");
      return new ModelAndView("redirect:/list.htm");
      }
  
      @RequestMapping(params = "delete", method = RequestMethod.POST)
      @Transactional
      public ModelAndView delete(@ModelAttribute("delete") User1 user,HttpServletRequest 
          request,HttpServletResponse response) throws Exception {
          userDAO.deleteUser(user);
          return new ModelAndView("redirect:list.htm");
      }
  
  
      @RequestMapping(params = "find", method = RequestMethod.POST)
      @Transactional
      public ModelAndView find(@ModelAttribute("find") User1 user,HttpServletRequest 
           request,HttpServletResponse response) throws Exception {  
                       userDAO.findUser(user);
                        return new ModelAndView("redirect:list.htm");
      }
  
  
      @RequestMapping(params = "update", method = RequestMethod.POST)
      @Transactional
      public ModelAndView update(@ModelAttribute("update") User1 user,HttpServletRequest 
          request,HttpServletResponse response) throws Exception {  
                       userDAO.updateUser(user);
                        return new ModelAndView("redirect:list.htm");
      }
  
  
      @RequestMapping(value = "/list", method = RequestMethod.GET)
       public ModelAndView list(HttpServletRequest request,
          HttpServletResponse response) throws Exception {
  
  
          ModelMap modelMap = new ModelMap();
          modelMap.addAttribute("userList", userDAO.listUser());
          modelMap.addAttribute("user", new User1());
          return new ModelAndView("list", modelMap);
       }
    }
  </code></pre>
  
  <p>My hibernateTemplate class is as follows</p>
  
  <p>UserDAOImpl.java</p>
  
  <pre><code>package project4;
  import project4.User1;
  import java.util.List;
  
  import org.hibernate.Query;
  import org.hibernate.Session;
  import org.hibernate.SessionFactory;
  import org.hibernate.cfg.Configuration;
  import org.springframework.orm.hibernate3.HibernateTemplate;
  import org.springframework.transaction.annotation.Propagation;
  import org.springframework.transaction.annotation.Transactional;
  
  public class UserDAOImpl1 implements UserDAO1 {
  
      private HibernateTemplate hibernateTemplate;
  
    public void setSessionFactory(SessionFactory sessionFactory) {
      this.hibernateTemplate = new HibernateTemplate(sessionFactory);
    }
  
     @Override
     @Transactional(propagation=Propagation.REQUIRED, readOnly=false)
     public void saveUser(User1 user) {
        try {
         System.out.println (user.getId ());
        hibernateTemplate.save(user);
        }catch (RuntimeException re){
              throw re;
        }
    }
  
    @Override
    @SuppressWarnings("unchecked")
    public List&lt;User1&gt; listUser() {
      List&lt;User1&gt; result = hibernateTemplate.find("from User1");
      System.out.println("hai");
      System.out.println(result);
      return result;
    }
  
      @Override
    public void deleteUser(User1 user) {
      hibernateTemplate.delete(user);
    }
  
      @Override
      public List&lt;User1&gt; findUser(User1 user) {
          List&lt;User1&gt; result =hibernateTemplate.find("from User1 where USER_ID=:" 
                     +user.getId());
          return result;
  
      }
  
      @Override
      public void updateUser(User1 user) {
          hibernateTemplate.update(user);
  
      }
  
   }
  </code></pre>
  
  <p>and my jsp class where i am trying to display the list is as follows</p>
  
  <p>list.jsp</p>
  
  <pre><code>&lt;%@ page language="java" contentType="text/html; charset=ISO-8859-1"
  pageEncoding="ISO-8859-1"%&gt;
  &lt;%@taglib uri="http://www.springframework.org/tags/form" prefix="form"%&gt;
  &lt;%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %&gt;
  
  &lt;!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org 
     /TR/html4/loose.dtd"&gt;
  &lt;html&gt;
   &lt;head&gt;
      &lt;meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"&gt;
      &lt;title&gt;Insert title here&lt;/title&gt;
    &lt;/head&gt;
    &lt;body&gt;
      &lt;form:form method="POST"&gt;
       &lt;table&gt;
        &lt;tr&gt;
          &lt;td width="50"&gt;Id&lt;/td&gt;
          &lt;td width="150"&gt;First Name&lt;/td&gt;
           &lt;td width="150"&gt;Last Name&lt;/td&gt;
            &lt;td width="100"&gt;Money&lt;/td&gt;
             &lt;td width="50"&gt;Currency&lt;/td&gt;
          &lt;/tr&gt;
     &lt;c:forEach items="${userList}" var="person"&gt;
        &lt;tr&gt;
          &lt;td&gt;&lt;c:out value="${person.id}" /&gt;&lt;/td&gt;
          &lt;td&gt;&lt;c:out value="${person.name}" /&gt;&lt;/td&gt;
          &lt;td&gt;&lt;c:out value="${person.password}" /&gt;&lt;/td&gt;
          &lt;td&gt;&lt;c:out value="${person.gender}" /&gt;&lt;/td&gt;
          &lt;td&gt;&lt;c:out value="${person.country}" /&gt;&lt;/td&gt;
          &lt;/tr&gt;
       &lt;/c:forEach&gt;
      &lt;/table&gt;
     &lt;/form:form&gt;
    &lt;/body&gt;
   &lt;/html&gt;
  </code></pre>
  
  <p>instead of using </p>
  
  <pre><code>  &lt;c:forEach items="${userList}" var="person"&gt;
  </code></pre>
  
  <p>i have also tried with </p>
  
  <pre><code>  &lt;c:forEach items="${user}" var="person"&gt;
  </code></pre>
  
  <p>and </p>
  
  <pre><code>  &lt;c:forEach items="${list}" var="person"&gt;
  </code></pre>
  
  <p>and my spring xml class is as follows</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:aop="http://www.springframework.org/schema/aop"   
    xmlns:tx="http://www.springframework.org/schema/tx"
    xmlns:context="http://www.springframework.org/schema/context"
     xmlns:util="http://www.springframework.org/schema/util"
   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/jdbc  http://www.springframework.org/schema
            /jdbc/spring-jdbc-3.0.xsd
     http://www.springframework.org/schema/tx   http://www.springframework.org/schema
          /tx/spring-tx-3.0.xsd
    http://www.springframework.org/schema/util  http://www.springframework.org/schema
          /util/spring-util-3.0.xsd
     http://www.springframework.org/schema/mvc   http://www.springframework.org/schema 
           /mvc/spring-mvc-3.0.xsd
     http://www.springframework.org/schema/context  http://www.springframework.org/schema
         /context/spring-context-3.0.xsd"&gt;
  
   &lt;mvc:default-servlet-handler /&gt;
    &lt;mvc:annotation-driven /&gt;
   &lt;context:annotation-config/&gt;
  
  &lt;bean  
  class="org.springframework.web.servlet.mvc.support.ControllerClassNameHandlerMapping"/&gt;
  
  
  &lt;bean id="urlMapping"  
      class="org.springframework.web.servlet.handler.SimpleUrlHandlerMapping"&gt;
      &lt;property name="mappings"&gt;
          &lt;props&gt;
              &lt;prop key="index.htm"&gt;indexController&lt;/prop&gt;
  
  
          &lt;/props&gt;
      &lt;/property&gt;
  &lt;/bean&gt;
  
  
  
  &lt;bean id="viewResolver"
        class="org.springframework.web.servlet.view.InternalResourceViewResolver"
        p:prefix="/WEB-INF/jsp/"
        p:suffix=".jsp" /&gt;
  
  
  &lt;bean name="cController.do" class="project4.CController" &gt;
    &lt;property name="userDAO" ref="myUserDAO"/&gt;
  
  &lt;/bean&gt;
  
  
  &lt;bean name="indexController"  
      class="org.springframework.web.servlet.mvc.ParameterizableViewController"
          p:viewName="index" /&gt;
  
  &lt;/beans&gt;
  </code></pre>
  
  <p>this is only a part of the xml config file as i use two xml files.</p>
  
  <p>I am able to save the data in the database but when i try to display the data i am getting the following error</p>
  
  <pre><code>type Status report
  
  message /Spring/WEB-INF/jsp/list.jsp
  
  description The requested resource (/Spring/WEB-INF/jsp/list.jsp) is not available.
  </code></pre>
  
  <p>and i am getting the url as </p>
  
  <pre><code>http://localhost:8080/Spring/list.htm
  </code></pre>
  
  <p>help needed plz</p>