title: How to display data of objects in JSP
body: <p>I have stored some user details through a register form into db (hibernate and spring). I want to display the user details of all users in a separate JSP page.Could anyone please tell me how to do that? </p>
  
  <p>Below is my code of controller</p>
  
  <pre><code>@Controller
  public class RegisterController {
  
      @Autowired
      private UserDao userDao;
  
      @RequestMapping(value = "/registerForm.htm", method = RequestMethod.GET)
      public ModelAndView registerPage(ModelMap map) {
          User user = new User();
          map.addAttribute(user);
          return new ModelAndView("registerForm", "command", user);
  
      }
  
      @RequestMapping(value = "/registerProcess.htm", method = RequestMethod.POST)
      public ModelAndView registerUser(@ModelAttribute("user") User user, Model model) {
  
          model.addAttribute("userName", user.getUserName());
          model.addAttribute("password", user.getPassword());
          model.addAttribute("emailId", user.getEmailId());
          System.out.println("user is " + user);
          System.out.println("userdao is" + userDao);
          userDao.saveUser(user);
          return new ModelAndView("registerProcess", "user", user);
  
      }
  
  }
  </code></pre>
  
  <p>code inside userdao</p>
  
  <pre><code>public void saveUser(User user) {
  
      Session session=getSessionFactory().openSession();
      Transaction tx;
      tx=session.beginTransaction();
  
      session.persist(user);
      tx.commit();
  
  }
  </code></pre>